main :: IO ()
main = putChar =<< solve <$> getLine <*> getLine <*> getLine

solve :: String -> String -> String -> Char
solve = 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
