#include <iostream>
using namespace std;
int n, m, x, y;
int res = 0;
bool st[11][11];
int dx[] = {1, 1, 2, 2, -1, -1, -2, -2};
int dy[] = {2, -2, -1, 1, 2, -2, 1, -1};
void dfs(int sx, int sy, int u) {
if (u == n * m - 1) {
res ++;
return;
}
for (int i = 0; i < 8; i ++) {
int a = sx + dx[i], b = sy + dy[i];
if (a < 0 || a >= n || b < 0 || b >= m) continue;
if (st[a][b] == true) continue;
st[a][b] = true;
dfs(a, b, u + 1);
st[a][b] = false;
}
}
int main() {
std::ios::sync_with_stdio(false); // 不加这个优化,最后一个用例就会超时
int T;
cin >> T;
while(T --) {
cin >> n >> m;
cin >> x >> y;
res = 0;
st[x][y] = true;
dfs(x, y, 0);
cout << res << endl;
st[x][y] = false; // 恢复现场
}
return 0;
}