print(({'A' : 'T', 'T' : 'A', 'C' : 'G', 'G' : 'C'}[eval(input())]))
print(("ATCG"["TAGC".find(eval(input()))]))
print(({"A": "T", "T": "A", "C": "G", "G": "C"}[eval(input())]))

print(("ATCG"["TAGC".find(eval(input()))]))

-print(({"A": "T", "T": "A", "C": "G", "G": "C"}[eval(input())])) +print(("ATCG"["TAGC".find(eval(input()))]))