Universal Cup Judging System

Universal Cup

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓
统计

Panda is a puzzle designer and decides to create a two-dimensional maze based on an arrow-following theme. This maze is a grid with $N$ rows and $M$ columns. Each cell contains an arrow: L (Left), R (Right), U (Up), or D (Down).

Cells are indexed with $(x, y)$, where $x$ is the row ($1 \le x \le N$) and $y$ is the column ($1 \le y \le M$). The top-left corner is $(1, 1)$ and the bottom-right corner is $(N, M)$. The player starts at position $(1, 1)$, and proceeds in discrete steps until reaching $(N, M)$ for the first time. Each step consists of the following two actions performed in order:

  1. Move: Move one step in the direction of the arrow in your current cell. You only remain in your current cell if the attempted move would take you outside the maze.
  2. Flip: After the move (or non-move) from step $1$, the arrow in the cell where you were before the move changes to its opposite direction (i.e., change L to R, R to L, U to D, and D to U). If you didn't move, you flip the arrow in your current cell.

Panda wants to design a maze, with a maximum size of $8 \times 8$, such that a player starting at $(1, 1)$ and following the rules reaches $(N, M)$ in exactly $k$ steps.

Input

The first line contains an integer $T$ ($1 \le T \le 2 \times 10^4$), denoting the number of test cases.

Each test case contains an integer $k$ ($1 \le k \le 10^6$) in a single line, which is the required number of steps for the player to exit the maze.

It is guaranteed that the sum of $k$ over all the test cases does not exceed $8 \times 10^7$.

Output

For each test case, if it is impossible to design such a maze, output -1 -1 in a single line. Otherwise, first output one line containing two integers $N, M$ ($1 \le N, M \le 8$), representing the size of the maze. Then output $N$ lines, with $M$ characters per line, representing the maze. Every character in the maze is one of L, R, U, D. You must ensure that the number of operations required to go from $(1, 1)$ to $(N, M)$ is exactly $k$.

Example

Sample Input 1

5
1
4
9
16
25

Sample Output 1

1 2
RR
2 2
LU
RD
3 2
LU
DR
LL
3 2
LU
UR
LL
1 6
LLRLLR

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.