def a?(i, j, lines)
  return false if i > 6 || j > 6
  [lines[i+1][j], lines[i][j+1], lines[i+1][j+1]].all? {|e| e == 1}
end

def b?(i, j, lines)
  [lines[i+1][j], lines[i+2][j], lines[i+3][j]].all? { |e| e == 1 }
end

def c?(i, j, lines)
  [lines[i][j+1], lines[i][j+2], lines[i][j+3]].all? { |e| e == 1 }
end

def d?(i, j, lines)
  [lines[i+1][j-1], lines[i+1][j], lines[i+2][j-1]].all? { |e| e == 1 }
end

def e?(i, j, lines)
  [lines[i][j+1], lines[i+1][j+1], lines[i+1][j+2]].all? { |e| e == 1 }
end

def f?(i, j, lines)
  [lines[i+1][j], lines[i+1][j+1], lines[i+2][j+1]].all? { |e| e == 1 }
end

def g?(i, j, lines)
  [lines[i][j+1], lines[i+1][j-1], lines[i+1][j]].all? { |e| e == 1 }
end

def form?(i, j, lines)
  if a?(i, j, lines)
    'A'
  # elsif b?(i, j, lines)
  #   'B'
  # elsif c?(i, j, lines)
  #   'C'
  # elsif d?(i, j, lines)
  #   'D'
  # elsif e?(i, j, lines)
  #   'E'
  # elsif f?(i, j, lines)
  #   'F'
  # elsif g?(i, j, lines)
  #   'G'
  end
end

def foo
  while true
    lines = []
    while gets
      break if $_ =~ /^\n/
      lines << $_.split('').map(&:to_i)
      break if lines.size == 8
    end

    next if $_ =~ /^\n/
    break if $_.nil?

    form = nil
    lines.each.with_index do |line, i|
      line.each.with_index do |char, j|
        next if char.zero?
        form = form?(i, j, lines)
        break if !form.nil?
      end
      break if !form.nil?
    end
    puts form
  end
end

foo