import Data.List
main = getContents >>= putStrLn . solve 'a' . lines

solve :: Char -> [String] -> String
solve 'a' [a : as, bs, cs] = solve a [as, bs, cs]
solve 'a' _= "A"
solve 'b' [as, b : bs, cs] = solve b [as, bs, cs]
solve 'b' _ = "B"
solve _ [as, bs, c : cs] = solve c [as, bs, cs]
solve _ _ = "C"
