13452 - Walk on the tree   

Description

You are given a binary tree of N vertices numbered from to N.

There are Q qustions.

Print the every direction if you want to walk from node A to node B. 

P: move to parent

R: move to right child

L: move to left child

Input

The first line contains a single integer N (2N3000).

Next N lines contain 2 integers, represent the left child and the right child of the i th node. (and 0 means empty)

Next line contains a integer Q (1Q3000);

The next Q lines contain two integers, A, B.

Output

For each question, output every direction that walks from node A to node B. 

Remember add a new line in the end of each question.

Sample Input  Download

Sample Output  Download

Tags




Discuss