#include<bits/stdc++.h>
using namespace std;
const int MAX = 10;
int t, n, m, x, y, ans, k;
bool v[MAX][MAX];
int d[8][2] = {-2, 1, -1, 2, 1, 2, 2, 1, 2, -1, 1, -2, -1, -2, -2, -1};
void dfs(int x, int y, int cnt){
if(cnt == k){
ans++;
return ;
}
for(int i=0; i<8; i++){
int a = x+d[i][0], b = y+d[i][1];
if(a<0 || a>=n || b<0 || b>=m) continue;
if(v[a][b]) continue;
v[a][b] = true;
dfs(a, b, cnt+1);
v[a][b] = false;
}
}
int main(){
scanf("%d", &t);
while(t--){
scanf("%d%d%d%d", &n, &m, &x, &y);
k = n*m, ans = 0;
memset(v, false, sizeof v);
v[x][y] = true;
dfs(x, y, 1);
cout<< ans<< endl;
}
return 0;
}