In the event of technical difficulties with Szkopuł, please contact us via email at firstname.lastname@example.org.
If you are familiar with IRC chat, the support team is also reachable on PIRC network (
#szkopul channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
Let us consider a circuit consisting of gates. The gates are numbered from to . Each gate has a certain number of inputs and exactly one output. Each of them (inputs and outputs) may be in either one of the states , or . Each input is connected to exactly one output of some gate. Input's state equals the state of the output it is connected to. Each output may be connected to an arbitrary number of inputs. The gates with numbers and are special - they don't have any input at all while their outputs are always in the following states: for a gate with a number , for a gate with a number . We say that the state of the output of a gate (in short: gate's state) is valid, if:
We say that a circuit's state is valid if all the states of its gates are valid. We say that a gate's state is fixed if the gate is in the same state in all circuit's valid states.
Write a programme that:
The first line of the standard input contains the number of gates , . The following lines contain the descriptions of gates' connections - line no. describes inputs of the gate no. . There is the number of inputs of this gate, followed by numbers of gates, . Those are the numbers of gates whose outputs are connected to successive inputs of the gate's no. . Numbers in each line are separated by single spaces. The total number of all inputs of all gates does not exceed .
Your programme should write lines to the standard output. Depending on the state of gate no. , 'th line should contain:
For the input data:
5 2 0 1 2 4 2 2 2 4
the correct result is:
0 1 1/2 ? ?
Task author: Bartosz Walczak.