
Nurikabe is a pencil puzzle from Japan. You are given a rectangular grid. Each cell is either an island cell (white) or a water cell (black), and some island cells carry a number from 1 to 9. A board is filled in correctly when all three rules below hold.
Decide whether a filled board is correct.
A rule with nothing to apply to holds. A board with no water cell satisfies the second rule, and a board with one row or one column has no 2×2 block.
The first line contains T, the number of boards.
The first line of each board contains the row count N and the column count M, separated by a space. The next N lines contain the rows of the board, one row per line. Each row is a string of M characters from 123456789.#, where # is a water cell, a digit is a numbered island cell, and . is an island cell without a number.
For each board, print YES on its own line if the board is filled in correctly, and NO otherwise.