ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

1092. Transversal

Time limit: 1.0 second
Memory limit: 64 MB
Consider a square table of size 2N+1 by 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 of the input 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.


The first line of the output should contain the words "No solution" if a necessary sequence of operations does not exist. Otherwise, the first line of the output should contain the words "There is solution:" and the next lines should contain a sequence of operations that leads to the required result. Each of these lines should describe one transversal and should contain the numbers 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. The numbers should be separated with a space.
It is sufficient to give only one sequence of operations if there exist many.


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