404501: GYM101521 E Bacteria Experiment
Description
Jason is performing a bacteria growing experiment. There are two types of bacteria involved, the Lninelus and Rbaselus. Each bacteria have a fixed seed with 10 cells; we can also view it as a tree with 10 nodes in terms of graph theory:
He is doing the experiment on T growing plates, where each plate either started with a Lninelus seed or a Rbaselus seed. These two bacteria have a special property: every hour, a new cell (node) will grow and attach to an existing cell (node) with uniform probability. As a result, this maintains the tree structure.
Jason let the bacteria grow for n - 10 hours. Now, each plate is a tree with n nodes. But, he realized he forgot to label the plates! Given the structure of the tree for each plate, can you determine which seed it is grown from? Your solution will be accepted if the accuracy is at least 95%.
InputThe first line contains two integers T and n (900 ≤ T ≤ 1000, n = 1000).
The following T lines each describe an unrooted tree in n - 1 integers: p1, p2, ..., pn - 1. There is an edge between node i and pi (0 ≤ pi ≤ n - 1 and pi ≠ i). The nodes are labelled from 0 to n - 1 in each tree. The labels are shuffled randomly and do not indicate the growth order.
OutputOutput exactly T lines: for each tree in order of the input, output L if you think it is Lninelus; or R if you think it is Rbaselus.
ExampleInput3 15Output
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 0 0 0 0 0 1 0 0 0 0 0 3 0
14 0 0 2 4 5 6 7 8 9 10 11 12 13
RNote
L
R
The sample input does not satisfy the constraints of T and n; it serves to demonstrate the format.