The performer “Aquarius” there are two vessels, the first with a volume of A liters, the second with a volume of B liters, as well as a tap with water. Aquarius can perform the following operations:
- Fill vessel A (indicated by
>A
).
- Fill vessel B (indicated by
>B
).
- Pour water out of vessel A (denoted by
A>
).
- Pour water out of vessel B (denoted by
B>
).
- Pour water from vessel A into vessel B (indicated as
A>B
).
- Pour water from vessel B into vessel A (indicated as
B>A
).
The command to pour from one vessel to another results in either the first vessel being completely emptied or the second vessel being completely filled.
Input: The program receives as input three natural numbers A, B, N, not exceeding 10
4.
Output: It is necessary to display the Aquarius action algorithm, which allows you to get exactly N liters in one of the vessels, but if such an algorithm does not exist, then the program should display the text
Impossible
.
The number of operations in the algorithm should not exceed 105. It is guaranteed that if the problem has a solution, then there is a solution that contains no more than 105 operations.
Examples
# |
Input |
Output |
1 |
3
5
1 |
>A
A>B
>A
A>B
|
2 |
3
5
6 |
Impossible
|