#T365. 马走日
马走日
Description
The horse moves according to the "日" shape rule in Chinese chess.
Please write a program that, given a chessboard of size n×m and the initial position (x, y) of the horse, calculates the number of ways the horse can traverse all points on the chessboard without repeating any point.
Input Format
The first line is an integer T (T < 10), representing the number of test cases.
Each test case consists of a single line containing four integers: the size of the chessboard and the initial position coordinates n, m, x, y. (0 ≤ x ≤ n-1, 0 ≤ y ≤ m-1, m ≤ 5, n ≤ 5).
Output Format
For each test case, output a single line containing an integer, which is the total number of ways the horse can traverse the entire chessboard. Output 0 if it is impossible to traverse all points once.
1
5 4 0 0
32