Revenge Party
Regina has stolen Aaron from Cady, and now Cady wants to win him back! She invited Aaron to her house, but then he invited his friends, and they invited their friends and it's really getting out of hand. Wait, where did Aaron go?
Cady's house is an grid of rooms, and she is standing in the top-left room. To find Aaron as quickly as possible, she wants to walk through all the rooms exactly once and end up where she started. Cady can walk from any room to any orthogonally adjacent room.
What path does Cady need to take to check all the rooms exactly once?
Input
The first line consists of two integers, and
, indicating that there are
rows and
columns of rooms in the house.
Output
Output the path you will take to search all the rooms and end up where you started. This is a string of characters, representing moves up (U), down (D), left (L) or right (R). For example, if Cady goes down, then right, then up, then left, then her path is DRUL".
If this is not possible, output "No".
Clarifications
- If there are multiple answers, output any of them.
Example
Input 1
3 4
Output 1
DDRRRUULDLUL
Cady could take the following path:
Input 2
2 2
Output 2
DRUL
Cady only needs to walk in a circle.
Input 3
3 3
Output 3
No
It is impossible for Cady to cover all rooms exactly once.
Comments