import           Control.Monad
import           Data.Char

main :: IO ()
main = do
  [a, b, c] <- replicateM 3 getLine
  putChar $ solve 'a' a b c

solve :: Char -> String -> String -> String -> Char
solve 'a' ""       _        _        = 'A'
solve 'a' (x : xs) ys       zs       = solve x xs ys zs
solve 'b' _        ""       _        = 'B'
solve 'b' xs       (y : ys) zs       = solve y xs ys zs
solve 'c' _        _        ""       = 'C'
solve 'c' xs       ys       (z : zs) = solve z xs ys zs
