A = [0b11000000, 0b11000000]
B = [0b10000000, 0b10000000, 0b10000000, 0b10000000]
C = [0b11110000]
D = [0b01000000, 0b11000000, 0b10000000]
E = [0b11000000, 0b01100000]
F = [0b10000000, 0b11000000, 0b01000000]
G = [0b011000000, 0b11000000]

def matchable(source, target, width)
  return false  if source.length != target.length
  (9 - width).times{|n|
    found = true
    source.length.times{|l|
      p source[l] ^ target[l] >> n
      found = false   if source[l] ^ target[l] >> n != 0
    }
    return true  if found
  }
  return false
end

def cutFigure(figure)
  subFigure = Array.new
  figure.each{|n|
    subFigure << n  if n != 0
  }
  return subFigure
end

def findFigure(figure)
  source = cutFigure(figure)
  return "A"  if matchable(source, A, 2)
  return "B"  if matchable(source, B, 1)
  return "C"  if matchable(source, C, 4)
  return "D"  if matchable(source, D, 2)
  return "E"  if matchable(source, E, 3)
  return "F"  if matchable(source, F, 2)
  return "G"  if matchable(source, G, 3)
end

loop do
  figure = Array.new
  8.times{
    break if (input = gets) == nil
    figure << input.chomp.to_i(2)
  }
  puts findFigure(figure)
end