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