Horsey

Time limit: 0.2s Memory limit: 128MB Input: Output:

A herd of horseys is heading to the International Olympiad for Horses in Teams (IOHT).

Figure 1: Horseys heading to the IOHT.\text{Figure 1: Horseys heading to the IOHT.}

They are currently positioned at cell (0,0)(0, 0) on a rectangular board of size N×MN \times M. They can move only by making L-shaped jumps: WW tiles in one direction (either horizontal or vertical) and then HH tiles in a perpendicular direction.

Their goal is to reach the cell where the IOHT is held. However, they do not know its location in advance. They ask for your help to determine whether it is possible for them to visit every cell on the board using only these L-shaped jumps.

Input data

The first line of the input file contains a single integer TT, the number of test cases. TT test cases follow, each on a new line.

Each test case consists of:

  • a line containing integers NN, MM, HH, and WW.

Output data

The output file must contain TT lines, each consisting of a single string: the ii-th line must be YES if it is possible to visit every cell in the ii-th test case, and NO otherwise.

Constraints and clarifications

  • 1T10001 \leq T \leq 1000.
  • 2N,M10182 \leq N, M \leq {10}^{18}.
  • 1H,W10181 \leq H, W \leq {10}^{18}.
# Score Constraints
1 0 Examples.
2 22 N,M,H,W50N, M, H, W \leq 50.
3 17 N,M,H,W1000N, M, H, W \leq 1000 and the sum of N×MN \times M over the TT testcases does not exceed 107{10}^{7}.
4 61 No additional constraints.

Example 1

stdin

1
4 4 3 2

stdout

NO

Explanation

In the first sample case, not every cell is reachable using only 3×23 \times 2 L-shaped moves. All reachable cells are circled in red in the figure below.

Figure 2: Two possible moves and all reachable cells in the first sample case.\text{Figure 2: Two possible moves and all reachable cells in the first sample case.}

Example 2

stdin

2
2 2 5 7
8 8 1 2

stdout

NO
YES

Explanation

In the second sample case:

  • On the 2×22 \times 2 board, the horseys cannot make any moves, so not all cells are reachable.
  • On the 8×88 \times 8 board, it can be shown that all cells are reachable.

Log in or sign up to be able to send submissions!