Consider a square table of size (2N + 1) × (2N + 1) with a cells each containing the sign “+” or the sign “-”. We call an arbitrary set of 2N + 1 cells a transversal if each line and each column of the table contain exactly one cell belonging to the set.
By one operation you are allowed to change signs to opposite in all cells of one transversal. You are asked to determine if it is possible to obtain a table containing not more than 2N cells with the sign “+” by a sequence of such operations.
The first line contains a positive integer N not exceeding 20. The next 2N + 1 lines contain the table. They consist of the symbols “+” and “-” without spaces between them.
Output “No solution” if a necessary sequence of operations does not exist. Otherwise output in the first line “There is solution:” and in the next lines a sequence of operations that leads to the required result. Each of these lines should describe one transversal and should contain the integers from 1 to 2N + 1. Number K at position S means that the transversal includes the cell at the intersection of the line number S with the column number K.
If there exist many sequences of operations you may output any one.
There is solution:
1 2 3
2 3 1
1 3 2
3 1 2
Problem Author: Dmitry Filimonenkov
Problem Source: USU Open Collegiate Programming Contest March'2001 Senior Session