Before the start of a contest at the Petrozavodsk Training Camp,
Dima and Artyom weighed the winning chances for the Ural SU T34 team using a pan balance. The balance is complemented with a collection of N weights of masses a1, a2, …, aN. No two weights have the same mass. Dima put weights only on the left pan and Artyom put weights only on the right pan. It is unknown by whom and in which order the weights were put, but after putting each weight on the balance a record was made
on a sheet of paper: if the left pan outweighed, then the letter
L was written; if the right pan outweighed, then the letter R was
written; and in the case of equilibrium the letter E was written.
During this procedure, all weights from the collection were put
on the balance one by one. Having thus weighed their winning
chances, the team went to the contest.
After the contest, the sheet of paper with records of positions of the balance caught Sasha's eye. There was a sequence of N letters on the sheet, and for some reason there were no letters E. Knowing masses of the weights, Sasha wants to determine the order in which the weights were put on the balance.
Input
The first line contains the integer 1 ≤ N ≤ 50.
In the second line, masses of all weights are given. These are
different positive integer numbers not exceeding 1000. The third line contains the list obtained by Sasha in the form of N symbols L and R.
Output
Output the order in which the weights were put on the balance in
the form of N lines. Each line must contain the mass of a
weight and, after a space, a symbol L or R depending on who
(Dima or Artyom) put this weight on the balance. If no such order
can be found, output “I'm too stupid to solve this problem”. If there are many solutions, you may
output any of them.
Sample
input | output |
---|
3
10 20 30
LRL
| 10 L
20 R
30 L
|
Problem Author: Sergey Pupyrev
Problem Source: The XIth USU Programing Championship, October 7, 2006