### 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)
    prv = 0
    for x in (0...N)
      if flds[y][x] == 1
        prv += 1
        hsums[y][x] = prv
      else
        hsums[y][x] = prv = 0
      end
    end
  end
  #p hsums

  max_rct = 0

  for x in (0...N)
    seq = 0
    minh = N
    for y in (0...N)
      hs = hsums[y][x]
      if hs > 0
        seq += 1
        minh = hs if minh > hs
        rct = seq * minh
        max_rct = rct if max_rct < rct
      else
        seq = 0
        minh = N
      end
    end
  end

  puts max_rct
end