404501: GYM101521 E Bacteria Experiment

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Bacteria Experimenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

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%.

Input

The 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.

Output

Output 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.

ExampleInput
3 15
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
Output
R
L
R
Note

The sample input does not satisfy the constraints of T and n; it serves to demonstrate the format.

加入题单

算法标签: