Problem:
Score : 100 points

Problem Statement

On the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.

You are given a letter b as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base b.

Constraints

b is one of the letters A, C, G and T.

Input

Input is given from Standard Input in the following format:

b

Output

Print the letter representing the base that bonds with the base b.

Sample Input 1

A

Sample Output 1

T

Sample Input 2

G

Sample Output 2

C

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		AC2 ac = new AC2(s);
		
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			int ans = ac.getAC(l, r);
			System.out.println(ans);
		}
		
	}
	
}

class AC2 {
	String s;
	int[] acCounts;
	AC2(String s) {
		this.s = s;
		acCounts = new int[s.length()];
		boolean isBeforeA = false;
		int acCount = 0;
		for (int i = 0; i < s.length(); i++) {
			char ch = s.charAt(i);
			if (isBeforeA) {
				if (ch == 'C') {
					acCount++;
					acCounts[i] = acCount;
					isBeforeA = false;
					continue;
				}
			}
			acCounts[i] = acCount;
			isBeforeA = (ch == 'A')? true: false;
		}
	}
	int getAC(int l, int r) {
		return acCounts[r - 1] - acCounts[l - 1];
	}
}