Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Complementing DNA

By RasheedAbid · Limits 5s, 512 MB

In DNA strings, symbols ‘A’ and ’T’ are complements of each other, as are ‘C’ and ‘G’.

The reverse complement of a DNA string S is the string Sc formed by reversing the symbols of S, then taking the complement of each symbol (e.g., the reverse complement of “GTCA” is “TGAC”). You will be given with a DNA string S of length at most 1000. You task is to write a program that will display the reverse complement Sc of S.

Input

First line contains the number of test cases T. The following T lines contain the DNA sequences S

Output

For each line of input produce one-line output, displaying reverse complement string Sc.

Samples

InputOutput
1
AAAACCCGGT
ACCGGGTTTT

Explanation of the sample case: For the given string GTCA, we take the reverse, that is ACTG. Then we replace each letter with its compliments and get TGAC.

Discussion