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

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

d = {"A": "T", "T": "A", "C": "G", "G": "C"}
print((d[eval(input())]))

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