eolymp
bolt
Try our new interface for solving problems
Problems

Omicronian Domino

Omicronian Domino

On the planet Omicron Persei 8, Domino is the second popular entertainment after Earth television broadcasts. Omicronian Domino is the game in which a chain of bones is built. Each bone has two halves. Each half has a non-negative integer number of points written on it (the number of points does not exceed \textbf{100000}). The bones of the chain touch their halves only if the contacting halves have equal number of points. There are bones with all possible point combinations in Omicronian domino, and each bone is unique. Lrrr, the leader of Omicron Persei 8, lost his last domino game. This has not happened for a long time, because Lrrr usually ate his defeater. That is why Lrrr remains the most skillful dominoer on his planet. Though, he wishes to restore the chain of bones of that last game. He took the required bones, and immediately built a chain of length \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{100000}). Unfortunately, the chain turned out to differ from that last game. Lrrr does not want to rebuild the chain, and he decides to make several transformations with the chain. Each transformation consists of actions: \begin{enumerate} \item Bones with numbers \textbf{l} and \textbf{r} are taken such that the left half of \textbf{l}-th and right half of \textbf{r}-th have equal points (\textbf{0} ≤ \textbf{l} ≤ \textbf{r} < \textbf{n}). The subchain from \textbf{l} to \textbf{r} is cut from the chain. \item A shift \textbf{d} is taken (\textbf{0} ≤ \textbf{d} ≤ \textbf{r-1}). \textbf{d} bones are extracted from the left side of subchain. Then the left and right parts of the subchain are rotated and glued again. \item The result subchain is rotated if needed. \item The subchain is inserted into the chain to the position \textbf{p} (\textbf{0} ≤ \textbf{p} ≤ \textbf{n-(r-l+1)}), such that the chain stays correct. \end{enumerate} The example of a transformation: \includegraphics{https://static.e-olymp.com/content/d3/d35912c6c0be75d561c71a9b0484585278b54999.jpg} Lrrr wants to make not more than \textbf{n} transformations. Otherwise, it is better to rebuild the chain from scratch. \InputFile First line contains number \textbf{n}. Second line contains \textbf{n+1} numbers separated by spaces - the points of the bones of the chain Lrrr wants to get. Third line contains \textbf{n+1} - the points of the bones of the chain that Lrrr has just built. \OutputFile In the first line output "\textbf{No}" if it is impossible to get the desired chain using at most n transformations. Otherwise output "\textbf{Yes}" in the first line. In each of next lines output the description of the current transformation: numbers \textbf{l}, \textbf{r}, \textbf{d}, then letter "\textbf{R}" or letter "\textbf{N}", then number \textbf{p}. Separate all entities with a space. Letter "\textbf{R}" means that action \textbf{3} of the transformation should be performed. "\textbf{N}" otherwise. The transformation from the figure is described as: "\textbf{1 3 1 R 3}".
Time limit 2 seconds
Memory limit 64 MiB
Input example #1
1
1 2
1 2
Output example #1
Yes
Author Кочетов Николай
Source Osipovsky Cup - 2013