a = [1,0,0]
idx = {"A"=>0,"B"=>1,"C"=>2,"A\n"=>0,"B\n"=>1,"C\n"=>2}

while str = gets do
b = []
b = str.split(",")
a[idx[b[0]]] , a[idx[b[1]]] = a[idx[b[1]]],a[idx[b[0]]]

end

if a[0] == 1
puts "A"
elsif a[1] == 1
puts"B"
else
puts"C"
end