P17168 [CEOI 2026] Vim
Description
It would be hard to find anything more **geeky** than the oldschool Vim - an editor in which we can do things that we could only dream of in "regular" editors. That is, if we are willing to invest a week of learning and a month of practice so that the unusual but powerful commands it offers become our "muscle memory". Well, just like in other editors, in Vim we have a **cursor**, which is always located on one of the characters. Initially, it is located on the first character of the text, and just like in other editors, in Vim there is a **clipboard**, which is intended for storing (and indirectly copying and moving) pieces of text. The clipboard is initially empty.
In this task, we will assume that there is exactly one `-` (minus) character in the editor at the beginning, and our goal is to finish with exactly $n$ consecutive minus signs. We will use four commands to help us with this:
- `h`: If the cursor is on the first character, then this command does nothing, otherwise it moves the cursor to the character on the left.
- `l`: If the cursor is on the last character, then this command does nothing, otherwise it moves the cursor to the character on the right.
- `Y`: The sequence of characters extending from the cursor position to the end of the text is copied to the clipboard, "overwriting" any previous contents of the clipboard. (If the cursor is on the first character of the text, the entire text will be copied to the clipboard.)
- `P`: A copy of the text stored in the clipboard is inserted before the character on which the cursor is located, and the cursor is moved to the last inserted character. The contents of the clipboard are not changed. If the clipboard is empty, nothing happens.
Write a program that reads the number $n$ and prints the minimum number of commands needed to finish with exactly $n$ consecutive `-` characters in Vim under the described conditions. The program should also print an example of a sequence with the minimum number of commands.
Input Format
The first line contains the number of test cases $t$. The next $t$ lines contain test cases with the desired string length $n$.
Output Format
For each test case, print the required minimum number of commands and an example of such a sequence of commands on its own line.
Explanation/Hint
### Comment
As we can see in the following table, in the first case, the sequence `YPYPhPYPPP` gives the correct result. The `=` character in the Screen column represents the `-` character on which the cursor is located.
| Step | Command | Screen | Clipboard |
|:-:|:-:|:-:|:-:|
| $0$ | | `=` | (empty) |
| $1$ | `Y` | `=` | `-` |
| $2$ | `P` | `=-` | `-` |
| $3$ | `Y` | `=-` | `--` |
| $4$ | `P` | `-=--` | `--` |
| $5$ | `h` | `=---` | `--` |
| $6$ | `P` | `-=----` | `--` |
| $7$ | `Y` | `-=----` | `-----` |
| $8$ | `P` | `-----=-----` | `-----` |
| $9$ | `P` | `---------=------` | `-----` |
| $10$ | `P` | `-------------=-------` | `-----` |
### Constraints
- $1\le t\le 100$
- $1\le n\le 10^7$
### Subtasks
If you print only the correct number of commands, but no example or an incorrect example of a sequence of commands, you will receive half the points for that subtask.
- Subtask $1$ ($20$ points): $n\le 100$
- Subtask $2$ ($8$ points): $n\le 1000$
- Subtask $3$ ($18$ points): $n\le 10^4$
- Subtask $4$ ($18$ points): $n\le 10^5$
- Subtask $5$ ($18$ points): $n\le 10^6$
- Subtask $6$ ($18$ points): No additional constraints.