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 Java (OpenJDK 11.0.6) (judge verdict: Wrong Answer)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
	static boolean Valid(String S)
	{
		for (char C : S.toCharArray())
		{
			if (C != 'A' && C != 'C' && C != 'T' && C != 'G') return false;
		}
		return true;
	}
	
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		String S = BR.readLine();
		int Best = 0;
		for (int i = 0; i < S.length(); i++)
		{
			String substr = S.substring(i);
			for (int j = substr.length() - 1; j >= 0; j--)
			{
				String result = substr.substring(0, j);
				if (Valid(result)) Best = Math.max(Best, result.length());
			}
		}
		System.out.println(Best);
	}
}