patterns = {
  # ??????????????°????????????????????????1??¨?????????????????????????????¨??????
  # ??????????????????????????????????§????????????¨?????????????????????????´???????
  # A????????¨????????¨????????????????????????1??¨?????????????????????
  #   ?????????x???+1???y???+0???????????????x???+0???y???+1???????????????x???+1???y???+0???
  # ??¨??¨???(???????????¨???1??§????????°???????????¢??¨?????´??????)
  a: [[1, 0],  [0, 1],  [1, 1]],
  b: [[0, 1],  [0, 2],  [0, 3]],
  c: [[1, 0],  [2, 0],  [3, 0]],
  d: [[-1, 1], [0, 1],  [-1, 2]],
  e: [[1, 0],  [1, 1],  [2, 1]],
  f: [[0, 1],  [1, 1],  [1, 2]],
  g: [[1, 0],  [-1, 1], [0, 1]]
}

while line = gets
  inputs = [line.chomp.split('').map(&:to_i)]

  while (input = gets) && (input != "\n")
    inputs << input.chomp.split('').map(&:to_i)
  end

  inputs.each_with_index do |row, y|
    x = row.index(1)

    unless x.nil?
      # ?????????1??¨????????????????????¨????????????
      # ??????????????????????????????????????¢??????????????????????????????????????????
      patterns.each do |figure, points|
        matched = true
        points.each do |(_x, _y)|
          unless inputs[y + _y][x + _x] == 1
            matched = false
            break
          end
        end

        if matched
          puts figure.upcase
          break
        end
      end

      break
    end
  end
end