

main :: IO ()
main = do
    a <- getLine
    b <- getLine
    c <- getLine
    putStrLn $ (solve (a,b,c)):[]


solve = solveAux 'a'

solveAux :: Char -> (String,String,String) -> Char
solveAux 'a' ([],_,_) = 'A'
solveAux 'b' (_,[],_) = 'B'
solveAux 'c' (_,_,[]) = 'C'

solveAux 'a' (x:a,b,c) = solveAux x (a,b,c)
solveAux 'b' (a,x:b,c) = solveAux x (a,b,c)
solveAux 'c' (a,b,x:c) = solveAux x (a,b,c)



