A robot is stuck on a infinite two-dimensional grid. Rows are increasing from top to bottom while columns are increasing from left to right. The cell landing on the $i^{th}$ row, $j^{th}$ column is denoted as $(i, j)$.
The robot is initially located at the origin $(0, 0)$. Now, he plans to travel to cell $(X, Y)$ by executing a string command $S$ with length $N$, provided by you. $N$ must be at most $10^5$.
The command $S$ can only have four kinds of characters: U, D, L, R, which represents up, down, left and right respectively.
The robot will first execute the $1^{st}$ character of $S$, then the $2^{nd}$ character, and so on, all the way until the $N^{th}$ character. After that, it will execute the $1^{st}$ character, and the process repeats.
The execution of $1$ character inside $S$ is counted as $1$ operation. After $K$ operations, the robot will end its journey. If currently it lands on cell $(X, Y)$, your mission is considered completed.
Given $X$, $Y$ and $K$, your task is to decide the value of $N$, generate the command $S$, and complete the mission - the robot challenges you. Note that it might be impossible to complete the mission. In this case, report it.
Input
The only line contains three integers $X$, $Y$ and $K$.
Output
If it is impossible to arrive cell $(X, Y)$, output Impossible.
Otherwise, output Possible on the first line.
On the second line, output a single integer $N$ $(1 \le N \le 10^5)$, denoting the length of $S$.
On the third line, output $N$ characters, denoting the command $S$. $S$ must only contain U, D, L, R four characters.
Subtasks
For all test cases:
- $-10^{10} \le X, Y \le 10^{10}$
- $1 \le K \le 10^{10}$
| Subtask | Score | Additional Constraints |
|---|---|---|
| $1$ | $4$ | $K = 1$ |
| $2$ | $5$ | $(X, Y) = (0, 0)$ |
| $3$ | $9$ | $K \le 10^5$ |
| $4$ | $7$ |
$K = |X| + |Y|$ $K / gcd(|X|, |Y|) \le 10^5$ |
| $5$ | $14$ | If a solution exists, a solution with $N \le 300$ also exists. |
| $6$ | $16$ |
$X = 0$ $K \le 2 \times 10^5$ |
| $7$ | $17$ | $X = 0$ |
| $8$ | $28$ | No Additional Constraints |
Sample Test Cases
| Input | Output | |
|---|---|---|
| -2 4 6 | Possible 3 RRU |
|
The full command is |
||
| -2 4 6 | Possible 4 RURR |
|
The first two characters are executed twice, and the last two characters are executed once, which does the same thing as the previous command. |
||
| 0 3 7 | Possible 5 RRRLL |
|
| 0 3 6 | Impossible | |
Scoring: Per Subtask
Authored by s22f26
Appeared in 2026 Mini Comp 6 (Constructive Algorithms & Special Tasks)