
let rec read n = 
  if n <= 0 then [] 
  else let x = read_line () in 
       List.map int_of_string (Str.split (Str.regexp "") x) :: read (n - 1)

let rec split = function
  | [] -> ([], [])
  | [] :: rest -> split rest
  | (hd :: tl) :: rest -> 
     let (hr, tr) = split rest in
     (hd :: hr, tl :: tr)

let rec transpose mx = 
  match split mx with
  | ([],_) | (_,[])-> []
  | (hd,tl) -> hd :: transpose tl

let figure = function
  | [[1;1];[1;1]] -> "A"
  | [[1;1;1;1]] -> "B"
  | [[1];[1];[1];[1]] -> "C"
  | [[0;1;1];[1;1;0]] -> "D"
  | [[1;0];[1;1];[0;1]] -> "E"
  | [[1;1;0];[0;1;1]] -> "F"
  | [[0;1];[1;1];[1;0]] -> "G"
  | _ -> "H"

let _ = 
  try 
    while true do
      let lst = read 8 in
      let lst1 = List.filter (fun x -> List.fold_left (+) 0 x <> 0) lst in
      let lst2 = List.filter (fun x -> List.fold_left (+) 0 x <> 0) (transpose lst1) in
      print_endline (figure lst2);
      read_line ()
    done
  with
    End_of_file -> ()