142. Chess Knights

Problem Statement:
You are given an NxM (N rows numbered from 1 to N from to to bottom, and M columns numbered from 1 to M from left to right) chess board, and a knight at position (x,y) (x is the row number, and y is the column number). The knight can move like in the chess game (L shape moves, as shown in the image below).

It can move any number of moves as long as it doesn't fall of the board. Your task is to find how many squares the knight can strike (after 0 or more moves).

Input Format:
The first line of the input contains an integer T, the number of test cases. Followed by the test cases. Each test case contains four space separated integers on a single line N,M,x,y (1 ≤ N,M ≤ 200) (1 ≤ x ≤ N) (1 ≤ y ≤ M) representing the dimensions of the board and the starting position of the knight (as described above), respectively.

Output Format:
For each test case print a single line contains an integer representing the number of squares the knight can strike.

Sample Input:
2 2 2 1 2 3 3 2 1

Sample Output:
1 8

 Added by: alaa.jrad Added at: 2014-03-05 18:59:42 UTC Time Limit: 3 seconds Partial score: No Source: Tishreen University First Training Contest 2014