|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|10 초||1024 MB||1||1||1||100.000%|
Ichiro won the newest model cleaner as a prize of a programming contest. This cleaner automatically moves around in a house for cleaning. Because Ichiro’s house is very large, it can be modeled as an infinite two-dimensional Cartesian plane, whose axes are called X and Y. The positive direction of the Y-axis is to the left if you face the positive direction of the X-axis.
The cleaner performs a sequence of actions for cleaning. Each action consists of a turn and a run. In an action, first the cleaner turns right or left by 90 degrees, and then runs straight by an integer length to the direction that the cleaner faces. At the end of a day, the cleaner reports the log of its actions in the day to Ichiro, in order to inform him where it has cleaned and where it hasn’t.
Unlike common cleaners, this cleaner has human-like artificial intelligence. Therefore, the cleaner is very forgetful (like humans) and it is possible that the cleaner forgets the direction of a turn, or the cleaner only remembers the length of a run as a very rough range. However, in order to pretend to be operating correctly, the cleaner has to recover the complete log of actions after finishing the cleaning.
The cleaner was initially at the point (0, 0), facing the positive direction of X-axis. You are given the cleaner’s location after cleaning, (X, Y), and an incomplete log of the cleaner’s actions that the cleaner remembered. Please recover a complete log from the given incomplete log. The actions in the recovered log must satisfy the following constraints:
The input consists of a single test case. The first line contains three integers N (1 ≤ N ≤ 50), X, and Y (−109 ≤ X, Y ≤ 109). N represents the number of actions in the incomplete log. X and Y represent the cleaner’s location (X, Y) after cleaning. The i-th line of the following N lines contains a character Di and two integers LLi and LUi. Di represents the direction of the i-th turn: ‘L’, ‘R’, and ‘?’ represents left, right, and not recorded respectively. LLi and LUi represent a lower and upper bound of the length of the i-th run, respectively. You can assume 1 ≤ LLi ≤ LUi ≤ 55,555,555.
Display the recovered log. In the first line, display N, the number of actions in the log. In the i-th line of the following N lines, display the direction of the i-th turn in a character and the length of the i-th run separated by a single space. Represent a right turn by a single character ‘R’, and a left turn by a single character ‘L’. The recovered log must satisfy the constraints in the problem. If there are multiple logs that satisfy the constraints, you can display any of them. Display −1 in a line if there is no log that satisfies the constraints.
2 -3 4 L 2 5 ? 3 5
2 L 4 L 3
5 3 -4 ? 1 5 ? 1 5 ? 1 5 ? 1 5 ? 1 5
5 L 1 R 2 R 4 L 1 R 1