#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 10;
int x, y, res = 0;
bool st[N][N];
int n;
void dfs(int a, int b, int s)
{
if(s == x * y)
{
res ++;
return;
}
int dx[8] = {-2, 2, 1, -1, -2, 2, 1, -1};
int dy[8] = {1, 1, 2, 2, -1, -1, -2, -2};
for(int i = 0; i < 8; i ++)
{
int c = a + dx[i], d = b + dy[i];
if(c >= 0 && c < x && d >= 0 && d < y && st[c][d] == false)
{
st[c][d] = true;
dfs(c, d, s + 1);
st[c][d] = false;
}
}
}
int main()
{
cin >> n;
while(n --)
{
memset(st, false, sizeof st);
int a, b;
cin >> x >> y >> a >> b;
st[a][b] = true;
dfs(a, b, 1);
cout << res << endl;
res = 0;
}
return 0;
}