#include<iostream>
#include<cstring>
using namespace std;
const int N = 10;
bool found = false;
int n, m, cnt, sum;
bool st[N][N];
int r;
//能走的8个点
int dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2}, dy[8] = {1,2,2,1,-1,-2,-2,-1};
void dfs(int x, int y){
cnt ++; // cnt记录走了多少个格子
if(cnt == n * m){
sum ++ ; //sum记录一共有多少种走法
found = true; //found判断马从初始位置走,能不能走完所有格子
return ; //如果所有格子走完了,返回
}
for(int i = 0; i < 8; i++){
int a = x + dx[i], b = y + dy[i];
if(a >= 0 && a < n && b >= 0 && b < m && !st[a][b]){
st[a][b] = true;
dfs(a, b);
cnt --; //回溯
st[a][b] = false;
}
}
}
int main(){
cin >> r;
while(r--){
memset(st, 0, sizeof st);
found = false;
sum = 0;
cnt = 0;
int x, y;
cin >> n >> m >> x >> y;
st[x][y] = true;
dfs(x, y);
if(!found) cout << 0 << endl;
else cout << sum << endl;
}
}