Олимпиадный тренинг

Задача 38479. Quest


Задача

Темы:
The new quest, in which the participants must get out of the venue, is a rectangle of N × M rooms. Each room has four doors leading to the neighboring rooms, from the rooms on the edge of the rectangle the doors lead outside, through these doors you can
leave the territory of the quest.
At the beginning of the quest, there is a person in each room, and all doors are locked. After the start of the quest, the organizers remotely open the locking mechanism of one of the four doors in each room. Now the person in this room can open this door and go
into the next room, you cannot leave this room through the other three doors. In this case, it may turn out that the door connecting the two rooms will be unlocked only from one side, then you can only pass through this door from the side from which it will open, pass
it is impossible to go through the door in the opposite direction, if not this door is unlocked in the next room, but some other one. If the room is located on the edge of the territory and the door is open from this room to the outside, then, having passed through this door, the participant leaves the quest territory forever.
After starting the quest and unlocking the doors, the participants begin to move between the rooms. Each participant moves to an adjacent open room and continues to move until they leave the quest area. However, it is possible that some participants will endlessly move between rooms and never go outside.
The developers of the escape room asked you to make a plan for unlocking the doors, in which exactly K people will be able to get out of the territory of the escape room.
Input
The program receives as input three numbers N, M, K, 1 ≤ N≤ 100.1≤ M≤ 100.0 ≤ K≤ N.M. N and M – number of rows and columns in a rectangular quest plan, K – the number of people who must leave the quest.
Imprint
The program should output the plan of the quest territory in the form of N lines, each of which should contain M characters. The symbol corresponds to which door will be opened in this room and can be one of the following capital English letters: U (door to the upper room according to this plan), D (door to the lower room), L (door to the left room), R (door to the right room). It is necessary to derive any one suitable plan for solving the problem. If no suitable plan exists, the program should print a single line "IMPOSSIBLE".".
 
Examples
# Input Output Explanation
1 1
2
1
IMPOSSIBLE Quest area consists of 1 row and 2 columns. For any
way of opening the doors from the quest, exactly one will not be able to get out
man.
2 3
4
5
RDLD
ULUR
DURU
The quest area consists of 3 rows and 4 columns. From the quest
5 people must go. The figure below is a picture,
corresponding to the answer from the example. Arrows indicate
open doors, dots mark the rooms whose inhabitants
exit the quest.