using System;
using System.Linq;
using System.Collections.Generic;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC122.A();
        }

        class ABC122
        {
            public static void A()
            {
                switch (Read.Str())
                {
                    case "A": Console.WriteLine("T"); return;
                    case "T": Console.WriteLine("A"); return;
                    case "G": Console.WriteLine("C"); return;
                    case "C": Console.WriteLine("G"); return;
                }
            }
            public static void B()
            {
                var S = Read.Str();
                var hash = new HashSet<char>(new char[] { 'A', 'C', 'G', 'T' });
                int longest = 0;
                int current = 0;
                foreach(var c in S)
                {
                    if (hash.Contains(c))
                    {
                        current++;
                        longest = Math.Max(longest, current);
                    }
                    else
                    {
                        current = 0;
                    }
                }
                Console.WriteLine(longest);
            }
            public static void C()
            {
                var N = Read.Int();
                var Q = Read.Int();
                var S = Read.Str();
                var LR = Read.TupleInt(Q);


                var BIT = new Util.BIT(N);
                for(int i = 0; i < N - 1; ++i)
                {
                    if(S[i]=='A' && S[i + 1] == 'C') { BIT.Add(i + 1, 1); }
                }
                foreach(var lr in LR)
                {
                    Console.WriteLine(BIT.Sum(lr.Item2 - 1) - BIT.Sum(lr.Item1 - 1));
                }
            }
            public static void D()
            {
                var N = Read.Int();

                var ACGT = new string[] { "A", "C", "G", "T" };
                var dp = new long[64, N + 1];
                for(int i = 0; i < 64; ++i)
                {
                    var str = ACGT[i / 16] + ACGT[(i % 16) / 4] + ACGT[i % 4];
                    dp[i, 3] = (str == "AGC" || str == "GAC" || str == "ACG") ? 0 : 1;
                }
                for(int j = 4; j <= N; ++j)
                {
                    for (int i = 0; i < 64; ++i)
                    {
                        var v1 = ACGT[i / 16];
                        var v2 = ACGT[(i % 16) / 4];
                        var v3 = ACGT[i % 4];

                        bool[] NG = new bool[4];

                        if (v2 == "A" && v3 == "C")
                        {
                            NG[2] = true;
                        }
                        if (v3 == "G" && (v1 == "A" || v2 == "A"))
                        {
                            NG[1] = true;
                        }
                        if (v2 == "G" && (v1 == "A" || v3 == "A"))
                        {
                            NG[1] = true;
                        }
                        for(int k = 0; k < 4; ++k)
                        {
                            if (!NG[k])
                            {
                                var target = (i % 16) * 4 + k;
                                dp[target, j] = (dp[target, j] + dp[i, j - 1]) % Util.P;
                            }
                        }
                    }
                }
                long total = Enumerable.Range(0, 64).Select(i => dp[i, N]).Sum() % Util.P;
                Console.WriteLine(total);
            }
        }
        class Util
        {
            public static readonly long P = 1000000007;
            public class BIT
            {
                int N; long[] array;
                public BIT(int m) { for (int n = 1; ; n *= 2) { if (n >= m) { N = n; array = new long[N + 1]; break; } } }
                public void Add(int idx, int v) { for (int x = idx; x <= N; x += x & -x) { array[x] += v; } }
                public long Sum(int idx) { long ret = 0; for (int x = idx; x > 0; x -= x & -x) { ret += array[x]; } return ret; }
            }

        }

        static class Read
        {
            static Queue<string> queue = new Queue<string>();
            static void Enqueue() { var ss = Console.ReadLine().Split(' '); foreach (var s in ss) { queue.Enqueue(s); } }
            public static int Int() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt32(queue.Dequeue()); }
            public static long Long() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt64(queue.Dequeue()); }
            public static string Str() { if (queue.Count == 0) { Enqueue(); } return queue.Dequeue(); }
            public static int[] IntN() { return Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray(); }
            public static long[] LongN() { return Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray(); }
            public static string[] StrN() { return Console.ReadLine().Split(' '); }
            public static Tuple<int, int>[] TupleInt(int n) { List<Tuple<int, int>> list = new List<Tuple<int, int>>(); for (int i = 0; i < n; ++i) { var ab = Read.IntN(); list.Add(new Tuple<int, int>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<long, long>[] TupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<string, string>[] TupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = Read.StrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<double, double>[] TupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); }
            public static long[,] LongMatrix(int r, int c)
            {
                var mat = new long[r, c];
                for (int i = 0; i < r; ++i)
                {
                    var x = Read.LongN();
                    for (int j = 0; j < c; ++j)
                    {
                        mat[i, j] = x[j];
                    }
                }
                return mat;
            }
            public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M)
            {
                Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
                for (int i = 0; i <= N; ++i)
                {
                    dict.Add(i, new HashSet<int>());
                }
                for (int i = 0; i < M; ++i)
                {
                    var ab = Read.IntN();
                    dict[ab[0]].Add(ab[1]);
                    dict[ab[1]].Add(ab[0]);
                }
                return dict;
            }
        }
    }
}


Measured memory_bytes: 11220