import Debug.Trace
import Data.Char (ord)

solve (a:as) bs cs 0 = solve as bs cs a
solve as (b:bs) cs 1 = solve as bs cs b
solve as bs (c:cs) 2 = solve as bs cs c
solve _ _ _ 0 = "A"
solve _ _ _ 1 = "B"
solve _ _ _ 2 = "C"

charToInt c = ord c - ord 'a'

main = do
    s <- getContents
    let [a, b, c] = map (map charToInt) . lines $ s
    putStrLn $ solve a b c 0
