#include <bits/stdc++.h>
using namespace std;
const int N = 20;
bool st[N][N];
int res;
int n,m,x,y;
void dfs(int a,int b,int cnt)
{
if(cnt == n * m)
{
res ++;
return;
}
for(int i = 0;i < 8;i ++)
{
int dx[8]={-2,-2,-1,1,2,2,1,-1},dy[8]={-1,1,2,2,1,-1,-2,-2};
int ta = dx[i] + a,tb = dy[i] + b;
if(ta < 0 || ta >= n || tb < 0 || tb >= m) continue;
if(st[ta][tb]) continue;
st[ta][tb] = true;
dfs(ta,tb,cnt + 1);
st[ta][tb] = false;
}
}
int main()
{
int T;
cin >> T;
while(T --)
{
cin >> n >> m >> x >> y;
res = 0;
memset(st,false,sizeof st);
st[x][y] = true;
dfs(x,y,1);
cout << res << endl;
}
return 0;
}