文件目录

#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, ans, t;
bool vis[15][15];
int dir[8][2] = {1, 2, -1, -2, -1, 2, 1, -2, 2, 1, -2, -1, -2, 1, 2, -1};
void dfs(int x, int y, int step)
{
    if (step == n * m)
        ans++;
    else
        for (int i = 0; i < 8; i++)
        {
            int xx = x + dir[i][0];
            int yy = y + dir[i][1];
            if (xx >= 0 && xx < n && yy >= 0 && yy < m && !vis[xx][yy])
            {
                vis[xx][yy] = true;
                dfs(xx, yy, step + 1);
                vis[xx][yy] = false;
            }
        }
}
int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n >> m >> x >> y;
        ans = 0;
        vis[x][y] = true;
        dfs(x, y, 1);
        cout << ans << endl;
        memset(vis, 0, sizeof(vis));
    }
    return 0;
}