#include<bits/stdc++.h>
using namespace std;
int t,n,m,x,y;
bool b[10][10]={0};
int s=0,k=0;
int dx[8]={-2,-2,-1,1,2,2,1,-1},
dy[8]={1,-1,-2,-2,-1,1,2,2};
void dfs(int x,int y,int s){
if(s==n*m){
k++;
return;
}
for(int i=0; i<8; i++){
int xx=x+dx[i];
int yy=y+dy[i];
if(xx<0||yy<0||xx>=n||yy>=m) continue;
if(b[xx][yy]==0){
b[xx][yy]=1;
dfs(xx,yy,s+1);
b[xx][yy]=0;
}
}
}
int main()
{
cin>>t;
for(int i=1; i<=t; i++){
memset(b,0,sizeof(b));
k=0;
cin>>n>>m>>x>>y;
b[x][y]=1;
dfs(x,y,1);
cout<<k<<endl;
}
return 0;
}