Triomino#3035

Triomino

1 second
64 megabytes
Easy

A triomino is a connected shape consisting of three squares. There are only two distinct types of such shapes, as shown in the picture. All other triominoes are just rotations of these two.

A rectangular field with rows and columns is considered filled with triominoes if:

  1. Each triomino lies entirely within the field and covers exactly three cells.

  2. Triominoes do not overlap.

  3. There are no more than two empty (not covered by a triomino) cells.

A field filled with triominoes can be represented as a rectangular table. The value denotes an empty (unfilled) cell. Identical natural values indicate that the cells belong to the same triomino, while different values correspond to different triominoes.

Write a program that, after analyzing the contents of several numerical two-dimensional tables, determines for each one whether it represents a correctly filled rectangular field with triominoes.

Input

The first line contains the number of rectangular tables (2 \le t \le 10). Then follow blocks with the following structure. The first line of each block contains two integers and (1 \le m \le 200, 1 \le n \le 200) — the number of rows and the number of columns in the corresponding table. Then follow rows each containing integers. The values of these integers range from to \left\lfloor \frac{mn}{3} \right\rfloor inclusive. The size of the input data does not exceed Kb.

Output

Print lines, each containing the word YES or NO (in uppercase Latin letters) indicating whether the corresponding table represents a correctly filled rectangular field with triominoes.

Note: Picture for the first block:

Examples

Example 1

Loading
Loading