QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 1024 MB Points totaux : 100

#6246. Spiral Square

Statistiques

Kian is trapped in a room and cannot see anything. We know that the floor of this room is an $n \times n$ square tiled with square tiles. Each tile has a unique number, and the tiles are numbered in a spiral pattern. For example, the figure below shows the numbering of the tiles for $n = 5$.

Kian knows there is a candle in the room and wants to reach it, but since the room is dark, he cannot see anything. He asks you to guide him on how much he needs to move in each direction to reach the candle, given the number of the tile Kian is standing on and the number of the tile the candle is on.

Input

The only line of input contains three space-separated integers $n$, $s$, and $d$, representing the side length of the room, the tile number Kian is standing on, and the tile number where the candle is located, respectively.

Output

On the first line of output, print a number and a character separated by a space. The number is the distance Kian must move horizontally, and the character is L if he must move to the left, or R if he must move to the right. If Kian does not need to move horizontally, this line is omitted.

On the second line of output, print a number and a character separated by a space. The number is the distance Kian must move vertically, and the character is U if he must move up, or D if he must move down. If Kian does not need to move vertically, this line is omitted.

Constraints

  • $1 \le n \le 2000$
  • $1 \le s \neq d \le n^2$

Examples

Input 1

5 1 25

Output 1

2 R
2 U

Input 2

5 3 22

Output 2

3 U

Input 3

15 67 24

Output 3

3 R
8 U

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.