Kotlin Heroes: Episode 7 |
---|
Finished |
Polycarp decided to generate a biome map for his game. A map is a matrix divided into cells $$$1 \times 1$$$. Each cell of the map must contain one of the available biomes.
Each biome is defined by two parameters: temperature (an integer from $$$1$$$ to $$$n$$$) and humidity (an integer from $$$1$$$ to $$$m$$$). But not for every temperature/humidity combination, a corresponding biome is available.
The biome map should be generated according to the following rules:
Help Polycarp generate a biome map that meets all the conditions described above (or report that this is impossible).
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 20$$$) — the number of test cases.
The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10$$$) — maximum temperature and humidity parameters.
The following $$$n$$$ lines contain $$$m$$$ integers each $$$a_{i,1}, a_{i, 2}, \dots, a_{i, m}$$$ ($$$0 \le a_{i, j} \le 100$$$), where $$$a_{i, j}$$$ — the biome identifier with the parameters $$$(i, j)$$$, if $$$a_{i, j} \neq 0$$$, otherwise the biome with such parameters is not available.
All biome identifiers are different, and there are at least two biomes available.
For each test case, print the answer in the following format:
4 2 3 0 2 5 0 1 0 3 5 0 3 4 9 11 1 5 0 10 12 0 6 7 0 0 2 2 2 0 0 5 1 2 13 37
1 3 5 2 1 2 8 11 9 4 3 5 1 5 6 12 10 9 4 3 5 6 7 -1 1 2 13 37
Name |
---|