def strip_zero matrix
    matrix2 = matrix.dup
    matrix2.each{|row|
        if row.all?{|elem| elem == 0}
            matrix2.delete(row)
        end
    }
    matrix2 = matrix2.transpose
    matrix2.each{|row|
        if row.all?{|elem| elem == 0}
            matrix2.delete(row)
        end
    }
    matrix2 = matrix2.transpose
    matrix2
end

lines = []
count = 0
while line = gets
    if line.chomp! != ""
        lines << line.split("").map(&:to_i)
        count += 1
        if count == 8
            lines = strip_zero lines
            type = ""
            case lines[0]
                when [1, 1] then type = "A"
                when [1] then type = "B"
                when [1, 1, 1, 1] then type = "C"
                when [0, 1] then type = "D"
                when [1, 1, 0] then type = "E"
                when [1, 0] then type = "F"
                when [0, 1, 1] then type = "G"
            end
            puts type
        end
    else
        lines = []
        count = 0
    end
end