Each data set corresponds to an instance of the problem and starts with two integral numbers: 1≤N≤1000 and 1≤M≤1000000. The data set continues with M pairs ±i ±j of signed numbers, 1≤i,j≤N. Each pair encodes a poll answer as follows:
Accepted answers to the poll question | Encoding |
I would be happy if at least one from i and j is elected. | +i +j |
I would be happy if at least one from i and j is not elected. | -i -j |
I would be happy if i is elected or j is not elected or both events happen. | +i -j |
I would be happy if i is not elected or j is elected or both events happen. | -i +j |
The input data are separated by white spaces, terminate with an end of file, and are correct.