P9762 [ROIR 2021] Splitting a Number Table (Day 1)
Background
**Translated from [ROIR 2021](http://neerc.ifmo.ru/school/archive/2020-2021.html) Day1 T2 [ Разбиение таблицы](http://neerc.ifmo.ru/school/archive/2020-2021/ru-olymp-regional-2021-day1.pdf)**。
Description
There is an $n \times m$ number table $a$, where $a_{i,j} = (i - 1) \times m + j$.
Now split this table into two tables $x, y$ so that $\max\{\sum x, \sum y\}$ is minimized.
More concretely, you may choose an $i$, then make one vertical cut between column $i - 1$ and column $i$, or make one horizontal cut between row $i - 1$ and row $i$. The two resulting tables are $x$ and $y$.
Please construct one valid plan.
Input Format
**This problem has multiple test cases.**
The first line contains an integer $t$.
The next $t$ lines each contain two integers $n, m$, representing the size of the table in this query.
Output Format
For each query, output a character $c$ and an integer $x$.
If you want to cut vertically, let $c$ be `V`, and let $x$ be your chosen $i$.
If you want to cut horizontally, let $c$ be `H`, and let $x$ be your chosen $i$.
If there are multiple solutions, output a vertical cut. If there are still multiple solutions, output the one with the smallest $x$.
Explanation/Hint
Constraints:
For all subtasks, $1 \le t \le 10^5$, $1 \le n, m \le 10^9$, $2 \le n \times m \le 10^9$.
| Subtask ID | Constraints | Score |
| :-: | :-: | :-: |
| $1$ | $t = 1$, $n, m \le 100$ | $20$ |
| $2$ | $t = 1$, $n, m \le 2 \times 10^3$ | $14$ |
| $3$ | $t = 1$, $n, m \le 10^7$ | $15$ |
| $4$ | $t \le 10^3$, $n \times m \le 10^4$ | $16$ |
| $5$ | $n = 1$ | $15$ |
| $6$ | No special constraints | $20$ |
Translated by ChatGPT 5