The Tree
시간 제한1초메모리 제한1024 MB
무한 이진 트리에서 방향과 깊이에 따라 색이 정해지는 부분 트리 칠하기 연산을 처리하고, 특정 정점의 현재 색을 답한다.
문제
You are given an infinite binary tree. The tree has the root and infinitely many vertices, each vertex has left son and right son, each vertex except the root has a parent.
Every vertex can be painted in one of colors or be colorless. Initially, all vertices are colorless.
You need to process two types of requests:
color(, ) You are given a vertex , paint vertex with color , and then callcolor(, ) for its left son andcolor(, ) for its right son . Note that this operation repaints the entire (infinite) set of vertices in the subtree of the vertex . Here is the operation of taking a division remainder. If the vertex has already been painted, then its color changes to the new one.- Given a vertex, output its current color.
입력
The first line contains two integers , --- the number of queries and colors, respectively (, ). This is followed by queries, each starts with an integer --- the type of the -th query.
If = 1, then an integer () is given in the line, the color that the vertex of the query should be colored. The next line describes the path to the vertex in the form of a non-empty string consisting of the characters 'L' and 'R'. This string specifies the path from the root of the tree to the vertex , where 'L' denotes going to the left son, and 'R' --- going to the right son.
If = 2, then the next line specifies the path to the vertex whose color should be output, described similarly to the previous query.
It is guaranteed that the sum of the lengths of the paths to all the vertices of the queries does not exceed .
출력
For each request of the second type print the color of the corresponding vertex on a separate line. If the vertex is colorless, print .