cho.sh
Notes
Loading...

DNA Decoding 2

Time limit

1s

Memory limit

2 MB

Problem

A DNA sequence consists only of the bases A, G, C, and T. Reduce the sequence according to the decoding table below until only one base remains.

AGCT
AACAG
GCGTA
CATCG
TGAGT

Let the two rightmost bases of the current sequence be X and Y in that order. Replace the two-character suffix XY with the single base found at row X and column Y of the table. Repeat this process until the sequence has length 1.

Given the DNA sequence, output the final base that remains after decoding.

Input

The first line contains the length N of the DNA sequence (1 ≤ N ≤ 20,000,000).

The second line contains a DNA sequence of length N consisting only of A, G, C, and T.

Output

Output the final remaining base on the first line.