#include #include #include #define LL long long #define Re register int using namespace std; const int N=15,M=8192+3; int n,m,o,V,T,A[N][N];LL dp[2][M]; inline void in(Re &x){ int f=0;x=0;char c=getchar(); while(c<'0'||c>'9')f|=c=='-',c=getchar(); while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar(); x=f?-x:x; } int main(){ // freopen("123.txt","r",stdin); in(T); while(T--){ in(n),in(m),V=(1<>1]; for(Re j=1;j<=m;++j){ o^=1; for(Re s=0;s<=V;++s)dp[o][s]=0; for(Re s=0;s<=V;++s)if(dp[o^1][s]){ Re L=(s>>j-1)&1,U=(s>>j+1-1)&1; if(A[i][j]){// 撤销操作 dp[o][s^(1<