PivotOJ

Determining Nucleotide Assortments

시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC ECNA 2022-2023BOJ 27612

문제

Genes 'R Us specializes in analyzing strands of DNA to look for anomalies, matches, patterns, or whatever specific items their customers are interested in. You may recall from high school biology that the DNA molecule consists of two chains wrapped around each other to form the well-known double helix. The chains are made up of four different types of nucleotides, each distinguished by a specific nitrogen base: adenine (A), thymine (T), guanine (G) and cytosine (C).

A recent customer of Genes 'R Us wants to be able to quickly determine which of the four types of nucleotides is most prevalent in a given section of DNA, as well as which are second, third and fourth most prevalent. For a given strand of DNA (which may contain tens of thousands of nucleotides) there may be many such sections where this information is desired. You've been asked to write an efficient program to answer such questions.

입력

Input starts with a string describing a DNA strand. This string consists of the characters A, T, G and C and have positive length n50000n \leq 50\,000. The next line contains a positive integer mm (m25000m \leq 25\,000) indicating the number of sections of the DNA strand to investigate. Following this are mm lines each containing a pair of integers sis_i eie_i, each indicating the start and ending positions of a section of the strand, where 1siein1 \leq s_i \leq e_i \leq n. Integer pairs are separated by a single space.

출력

For each section output a line containing a permutation of ATGC, where the first character indicates the most prevalent nucleotide in the section, the second character indicates the second most prevalent, and so on. Break any ties using the ordering ATGC (i.e., print an A before an equally occurring T, G or C, print a T before an equally occurring G or C, and so on).

예제

예제 1

입력
TATATGCTCT
3
1 10
6 10
6 6
출력
TACG
TCGA
GATC
코드를 제출하려면 로그인하세요.