main :: IO ()
main = putStrLn =<< winner <$> getLine <*> getLine <*> getLine

winner :: String -> String -> String -> String
winner = go 'a'
  where
    go 'a' [] _ _       = "A"
    go 'a' (x:xs) ys zs = go x xs ys zs
    go 'b' _ [] _       = "B"
    go 'b' xs (y:ys) zs = go y xs ys zs
    go 'c' _ _ []       = "C"
    go 'c' xs ys (z:zs) = go z xs ys zs