### constant

N = 5

### main

m = gets.to_i

m.times do
  flds = []
  N.times do
    line = gets.strip
    line = gets.strip if line.empty?
    flds << line.split.map(&:to_i)
  end
  #p flds

  hsums = N.times.map{[]}

  for y in (0...N)
    hsums[y][0] = flds[y][0]
    for x in (1...N)
      if flds[y][x] == 1
        hsums[y][x] = hsums[y][x - 1] + 1
      else
        hsums[y][x] = 0
      end
    end
  end
  #p hsums

  max_rct = 0

  for x in (0...N)
    for y in (0...N)
      min_hs = hsums[y][x]
      next if min_hs == 0

      max_rct = min_hs if max_rct < min_hs

      (y - 1).downto(0) do |y0|
        hs0 = hsums[y0][x]
        break if hs0 == 0
        min_hs = hs0 if min_hs > hs0
        rct = min_hs * (y - y0 + 1)
        max_rct = rct if max_rct < rct
      end
    end
  end

  puts max_rct
end