n = gets.to_i
n.times do
  ans = 0
  b = []
  5.times{ b << gets.split.map(&:to_i) }
  5.times do |i|
    5.times do |j|
      if b[i][j] == 1
        6.times do |k|
          6.times do |m|
            f = nil
            k.times do |p|
              m.times do |q|
                f = true if i + p > 4 || j + q > 4 || b[i+p][j+q] == 0
              end
            end
            ans = k * m if f.nil? && ans < k * m
          end
        end
      end
    end
  end
  p ans
  gets
end