#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 28;
int dx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};
bool g[N][N];
int n, m;
int res;
void dfs(int x, int y, int cnt)
{
if(cnt == n * m) res ++;
for(int i = 0; i < 8; i ++)
{
int a = x + dx[i], b = y + dy[i];
if(a < 0 || b < 0 || a >= n || b >= m) continue;
if(!g[a][b])
{
g[a][b] = true;
dfs(a, b, cnt + 1);
g[a][b] = false;
}
}
}
int main()
{
int T;
cin >> T;
while(T --)
{
int x, y;
cin >> n >> m >> x >> y;
memset(g, 0, sizeof g);
g[x][y] = true;
res = 0;
dfs(x, y, 1);
cout << res << endl;
}
return 0;
}
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 28;
int dx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};
bool g[N][N];
int n, m;
int res;
bool check()
{
for(int i = 0; i < n; i ++)
for(int j = 0; j < m; j ++)
if(!g[i][j]) return false;
return true;
}
void dfs(int x, int y)
{
if(check()) res ++;
for(int i = 0; i < 8; i ++)
{
int a = x + dx[i], b = y + dy[i];
if(a < 0 || b < 0 || a >= n || b >= m) continue;
if(!g[a][b])
{
g[a][b] = true;
dfs(a, b);
g[a][b] = false;
}
}
}
int main()
{
int T;
cin >> T;
while(T --)
{
int x, y;
cin >> n >> m >> x >> y;
memset(g, 0, sizeof g);
g[x][y] = true;
res = 0;
dfs(x, y);
cout << res << endl;
}
return 0;
}