{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"\u003cp\u003eGenetic engineering is fun. The scientists have gathered several DNAs and want to create something new out of those. Each DNAs can be represented as a sequence of bases A, G, T, C. Let DNA[a..b] be the subsequence of DNA starting from index a finishing in b inclusive, and DNA[a..] be the subsequence of DNA starting from index a to the end. Scientist can perform the following operations on the DNAs:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003ecross operation – they take DNA1 and DNA2 and numbers k1 and k2. Then two new DNAs are created: DNA3 \u003d DNA1[1..k1]+DNA2[k2+1..] and DNA4 \u003d DNA2[1..k2]+DNA1[k1+1..].\u003c/li\u003e\r\n\u003cli\u003emutate operation – they take a DNA, number k and one of the bases. Then they replace the base in position k in DNA with that base.\u003c/li\u003e\r\n\u003cli\u003ealso they need to know certain characteristics of those DNAs. So they can perform count operation – they take DNA and numbers k1 and k2 (k1 \u003c\u003d k2). This operation should return the number of A, G, T, C bases in DNA[k1..k2].\u003c/li\u003e\r\n\u003c/ul\u003e\u003cbr /\u003e\r\n\u003cp\u003eThe initial DNAs are numbered from 1 to n, where n is the amount of those DNAs. The new DNAs created in the cross operations are numbered with consecutive integers. You are to write a program to help scientists perform those operations.\u003c/p\u003e\r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line of input file contains number n – the amount of initial DNAs. Each of the following n lines contains the description of each DNA. The next line contains number q – the amount of operations to perform. The next q lines contain the description of each operation in the following form:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eCROSS id1 id2 k1 k2\u003c/li\u003e\r\n\u003cli\u003eMUTATE id k m\u003c/li\u003e\r\n\u003cli\u003eCOUNT id k1 k2\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\r\n\u003ch3\u003eConstraints\u003c/h3\u003e\r\n\u003cp\u003e1 \u003c\u003d n \u003c\u003d 20\u003cbr /\u003e\r\n1 \u003c\u003d q \u003c\u003d 30000\u003cbr /\u003e\r\nThe length of each initial DNA does not exceed 30000. The length of any DNA formed in cross operation won’t exceed 2000000000. Total amount of different DNAs won’t exceed 10000. It is guaranteed that all operations are correct.\r\n\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each count operation print four integers: the number of each of the bases in the given subsequence of the given DNA.\r\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\r\n\u003cpre\u003e\r\n\u003cb\u003eInput:\u003c/b\u003e\r\n2\r\nCTCGC\r\nTGCGG\r\n5\r\nMUTATE 1 2 A\r\nCOUNT 2 2 4\r\nMUTATE 2 1 G\r\nCROSS 2 1 1 5\r\nCOUNT 4 3 6\r\n\r\n\u003cb\u003eOutput:\u003c/b\u003e\r\n0 2 0 1\r\n0 2 0 2\r\n\r\n\u003c/pre\u003e\r\n"}}]}