Virtulandia
In the country of Virtualandia, there's a popular puzzle involving a table with M + 1 rows. The first M rows are green, and the last row, the M + 1-th, is blue. Each row contains N integers, each ranging from 0 to P - 1, inclusive. To solve the puzzle, you can add a green row to the blue row element-wise. If any number in the blue row exceeds P - 1, it is reduced by P. The puzzle is solved when all numbers in the blue row are zeros.
Your task is to write a program that solves this puzzle.
Input
The first line contains the number of test cases. For each test case, the first line provides the integers P, N, and M (1 ≤ N, M ≤ 100, 2 ≤ P ≤ 255). The following M lines each contain N integers representing the green rows. The next line contains N integers representing the blue row.
Output
For each test case, output the result on a separate line. If the puzzle cannot be solved, output the number 0. If it can be solved, output the number 1, followed by N integers indicating how many times each green row should be added to the blue row to solve the puzzle.