#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int in[5][5];
int count(int a,int b,int c,int d){
  bool h=true;
  loop(i,a,b+1)loop(j,c,d+1)if(in[i][j]!=1)h=false;
  if(!h)return 0;
  return (b-a+1)*(d-c+1);
}
int main(){
  int n;
  cin>>n;
  while(n--){
    rep(i,5)rep(j,5)cin>>in[i][j];
    int maxi=0;
    rep(a,5)loop(b,a,5)rep(c,5)loop(d,c,5)maxi=max(maxi,count(a,b,c,d));
    cout<<maxi<<endl;
  }
}