QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#8355. T3

统计

Little T has an $n \times n$ chessboard and many coins. He wants to place the coins on the board such that there is exactly one coin in each cell. Let the positions above the first row of the board from left to right be $\text{U}1, \text{U}2, \dots, \text{U}n$, and the positions below the last row from left to right be $\text{D}1, \text{D}2, \dots, \text{D}n$. Similarly, let the positions to the left of the first column and to the right of the last column from top to bottom be $\text{L}1, \text{L}2, \dots, \text{L}n$ and $\text{R}1, \text{R}2, \dots, \text{R}n$, respectively.

In each operation, Little T places a coin at one of these positions outside the board that is adjacent to a cell, and then pushes the coin into the board until it is exactly inside a cell. If there is already another coin in a cell, that coin is also pushed one cell further in the same direction. If any coin is pushed off the board, the operation is considered a failure. For example, the figure below shows $9$ valid operations on a $3 \times 3$ board.

Little T finds this process boring. Therefore, he assigns a number $U_i, D_i, L_i, R_i$ to each position $\text{U}i, \text{D}i, \text{L}i, \text{R}i$ outside the board, representing the number of operations performed at that position. After writing down the numbers, Little T realizes he cannot quickly find a valid sequence of operations. Can you help him find one?

Input

The first line contains an integer $n$, representing the size of the board.

The second line contains $n$ integers $U_i$, representing the number of operations at position $\text{U}i$.

The third line contains $n$ integers $D_i$, representing the number of operations at position $\text{D}i$.

The fourth line contains $n$ integers $L_i$, representing the number of operations at position $\text{L}i$.

The fifth line contains $n$ integers $R_i$, representing the number of operations at position $\text{R}i$.

Output

If there is no solution, output NO. Otherwise, output $n^2$ lines, each containing a string like $\text{U}i, \text{D}i, \text{L}i$, or $\text{R}i$, representing the position of that operation.

Examples

Input 1

3
0 0 1
1 1 0
3 0 1
0 1 1

Output 1

L1
L1
L1
L3
D1
R2
U3
R3
D2

Input 2

2
3 0
0 0
0 1
0 0

Output 2

NO

Note

Example $1$ corresponds to the image provided in the problem description.

In Example $2$, $U_1=3$, so it is clearly impossible to construct a valid solution.

Constraints

For all data, $1\leq n\leq 300$, $0\leq U_i,D_i,L_i,R_i$, and $\sum \left(U_i+D_i+L_i+R_i\right)=n^2$.

Subtask $1$ ($11$ points): $n\leq 3$.

Subtask $2$ ($15$ points): $D_i=R_i=0$.

Subtask $3$ ($19$ points): $D_i=0$.

Subtask $4$ ($25$ points): $n\leq 40$.

Subtask $5$ ($30$ points): No special restrictions.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.