#include using namespace std; void solve(){ auto f=[&](int i1,int j1,int i2,int j2){ int di=abs(i1-i2),dj=abs(j1-j2); if (di==0&&dj==0) return false; if (di==0||dj==0||di==dj) return true; return false; }; int h,w; cin>>h>>w; vector> a(h,vector(w)); for (int i=0;i>a[i][j]; int m=-2e9; for (int i1=0;i10) cout<<"infinite\n"; else cout<<"finite\n"; } int main(){ int t; cin>>t; while (t--) solve(); }