import java.lang.*;
import java.io.*;
import java.util.*;
class Main{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
static StringTokenizer stz = new StringTokenizer("");
static String nextLine() throws Exception {// 读取下一行字符串
return br.readLine();
}
static String next() throws Exception {// 读取下一个字符串
while (!stz.hasMoreTokens()) {
stz = new StringTokenizer(br.readLine());
}
return stz.nextToken();
}
static int nI() throws Exception {// 读取下一个int型数值
return Integer.parseInt(next());
}
static double nD() throws Exception {// 读取下一个double型数值
return Double.parseDouble(next());
}
static long nL() throws Exception {// 读取下一个double型数值
return Long.parseLong(next());
}
static void write(String str) throws Exception{
bw.write(str);
}
static String itoS(int i){
return Integer.toString(i);
}
static void wI(int i) throws Exception{
write(Integer.toString(i));
}
static void wL() throws Exception{
write("\n");
}
static void flush() throws Exception{
bw.flush();
}
public void print() throws Exception{
flush();
}
public static void main(String[] args) throws Exception{
Main main = new Main(); main.run(); main.print();
}
int T;
int n, m, sx, sy;
final int N = 10;
boolean[][] st = new boolean[N][N];
// 用于记录最后的值
int res;
int[] dx = {2,1,-1,-2,-2,-1,1,2};
int[] dy = {1,2,2,1,-1,-2,-2,-1};
void dfs(int x, int y, int cnt){
// 初始化
if (cnt == n * m){
res++; return;
}
st[x][y] = true;
for (int i = 0; i < 8; i++) {
int a = x + dx[i], b = y + dy[i];
if (a >= n || a < 0 || b >= m || b < 0) continue;
if (st[a][b]) continue;
dfs(a, b, cnt + 1);
}
// 最终还是会回来的, 所有多组数据也不需要重新初始化
st[x][y] = false;
}
public void run() throws Exception{
T = nI();
while (T-- > 0){
res = 0;
n = nI(); m = nI(); sx = nI(); sy = nI();
// 用全局变量来存贮
dfs(sx, sy, 1);
// 处理答案
wI(res);
wL();
}
}
}