Rotate The Matrix#13034

Rotate The Matrix

1 second
256 megabytes
Easy

Welcome to the contest with open arms , and hope you enjoy

MathModel

You are given a 2 \times 2 matrix. You may rotate the matrix by 90^\circ clockwise any number of times (including zero times). Your task is to determine whether it is possible to obtain a matrix whose value is exactly equal to a given integer .

A 2 \times 2 matrix has the form

\begin{bmatrix} a & b \\ c & d \end{bmatrix}

where , , , and are integers.

The value of this matrix is defined as a \times d- b \times c.

Input

The first line contains a single integer (1 \le t \le 10^4) — the number of test cases.

The first line of each test case contains a single integer (1 \le x \le 10^9) — the target value.

The next two lines represent the matrix a,b,c,d (1 \le a,b,c,d \le 10^4) — the matrix integers.

Output

For each test case, print "YES" if possible; otherwise, print "NO".

You can output the answer in any case (For example, the strings "yEs", "yes", "Yes", and "YeS" will be recognized as positive responses).

Examples

Example 1

Loading
Loading

Note

In the first test case, the matrix is

\begin{bmatrix} 3 & 2 \\ 9 & 4 \end{bmatrix}.

After rotating it once by 90^\circ clockwise, we obtain

\begin{bmatrix} 9 & 3 \\ 4 & 2 \end{bmatrix}.

Its value becomes

9 \times 2 - 3 \times 4 = 18 - 12 = 6

which equals the required .

In the fourth test case, start with

\begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix}.

After three clockwise rotations:

\begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} \;\xrightarrow{\text{rotate } 90^\circ}\; \begin{bmatrix} 7 & 5 \\ 8 & 6 \end{bmatrix} \;\xrightarrow{\text{rotate } 90^\circ}\; \begin{bmatrix} 8 & 7 \\ 6 & 5 \end{bmatrix} \;\xrightarrow{\text{rotate } 90^\circ}\; \begin{bmatrix} 6 & 8 \\ 5 & 7 \end{bmatrix}.

The value of the final matrix is

6 \times 7 - 8 \times 5 = 42 - 40 = 2.

Scoring

  1. Subtask ( points) : No additional constraints