ll@t; rep(t){ ll@h,@w,@a[h][w]; rep(y1,h){ rep(x1,w){ rep(y2,h){ rep(x2,w){ if(x1!=x2||y1!=y2){ if(x1==x2||y1==y2||x1+y1==x2+y2||x1-y1==x2-y2){ if(a[y1][x1]+a[y2][x2]>0){ wt("infinite"); goto next; } } } } } } } wt("finite"); next:; }