Guan has just learnt the four nucleobases in DNA: Adenine, Thymine, Cytosine and Guanine. Wait, GUANine. Guan is incredibly intrigued by this based named GUANine. "Was it named after me?" he thought to himself. "Surely it must be, I am so smart." After countless hours of searching Google for the origins of Guanine, his search turned out futile. There was no results found for "Wu Guanqun's brilliant discovery of new nucleobase Guanine." Devastated, he turns back to his lego DNA play set and starts constructing DNA sequences.
"ATTGCCGATTGACT," Guan made, "hmm, gene for awkwardness."
"GCTAGCTAGCGCGTAT," Guan made another gene sequence, "hmm, gene for being weird."
Guan starts off with an empty DNA string. He can then choose any one of four operations to do:
At any point in time, Guan can also have a "QUERY z" operation, which requires you to output the z-th nucleobase from the front. (0-indexed)
Guan can conduct up to N operations and queries in total. Each query/operation will be in the form "<command> <parameter>". Output only in a "QUERY" operation.
9 ADD_BACK C ADD_FRONT A ADD_BACK T ADD_FRONT A QUERY 2 SNIP_FRONT 1 ADD_FRONT G QUERY 0 QUERY 2
C G T