A very big corporation is developing its corporative network. In the beginning, each of the
Input Specification
Your program has to be ready to solve more than one test case. The first line of the input will contain the number
– asking the length of the path from the enterprise to its serving center in the moment; – informing that the serving center is linked to the enterprise .
The test case finishes with a line containing the letter O
. The
Output Specification
The output should contain as many lines as the number of
Sample Input
1
4
E 3
I 3 1
E 3
I 1 2
E 3
I 2 4
E 3
O
Sample Output
0
2
3
5
Comments