char = {"A" => true, "B" => false, "C" => false}
while (swap = gets)
  swap = swap.chomp.split(",")
  char[swap[0]], char[swap[1]] = char[swap[1]], char[swap[0]]
end
if char["A"]
  puts "A"
elsif char["B"]
  puts "B"
else
  puts "C"
end