시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 10 | 6 | 6 | 66.667% |
Little girl Masha is looking at the wall in her room. The wall is tiled with square tiles, but some of the tiles are replaced with lamps. So it is possible to consider the wall to be a rectangle of n × m, some cells contain tiles, other cells contain lamps.
Masha has paints of k different colors. Consider continuous vertical or horizontal segments of tiles, having an edge of the wall or a lamp at each of its ends. Masha wants to paint all tiles in such way, that any such segment has all tiles painted in different colors. Masha will not paint lamps. She doesn't have to use all the colors.
Help Masha to paint the wall.
Input contains several test cases. The first line contains the number of test cases t.
Each test case is described by several lines. The first line contains three integers: n, m, k (1 ≤ n, m ≤ 100, 1 ≤ k ≤ max(n, m)) — the size of the wall and the number of paints Masha has.
The following n lines contain m integers aij each:
The total number of tiles and lamps in all test cases of one input doesn't exceed 105.
For each test case first print the answer:
2 4 3 2 0 1 0 1 0 1 1 0 1 0 1 0 3 4 2 0 1 0 1 1 0 1 1 1 1 1 0
YES 0 2 0 2 0 2 1 0 1 0 1 0 NO