import Data.List
main = interact $ unlines . map (figure_on_surface . dropWhile (=='0')) . parse . lines

parse [] = []
parse ("":xs) = parse xs
parse xs = concat (take 8 xs) : parse (drop 8 xs)
 
figure_on_surface xs
 | isPrefixOf "1100000011" xs = "A"
 | isPrefixOf "1000000010000000100000001" xs = "B"
 | isPrefixOf "1111" xs = "C"
 | isPrefixOf "1000000110000001" xs = "D"
 | isPrefixOf "11000000011" xs = "E"
 | isPrefixOf "100000001100000001" xs = "F"
 | isPrefixOf "110000011" xs = "G"