| 2023 Abakoda Long Contest |
|---|
| Закончено |
Alice, Bob, and Cindy are having a blast playing the hot new game Injurious Company, an indie horror survival game where players assume the role of underpaid laborers who must persevere through ludicrously unsafe working conditions just to earn scraps for their day's wage (maybe the real horror is capitalism).
The gang are located at position $$$(x, y)$$$ (using the usual Cartesian coordinate system) and must return back to their ship, located at the origin $$$(0, 0)$$$. But they have to move strategically in order to dodge the monsters that are coming after them! The strategy guide describes a winning strategy according to $$$n$$$ pieces of information, each described by an integer $$$K_i$$$ and a direction $$$dir_i$$$ (each of which is H or V). This means that on their $$$i$$$th move they choose a direction $$$d_i$$$ and a number of steps $$$k_i$$$—then, they head $$$k_i$$$ steps in the direction of $$$d_i$$$. Their choice is subject to the following restrictions:
Determine if it is possible for them to return to their ship alive, and if so, provide a series of moves that they can take. Also, please answer $$$T$$$ different test cases per file.
The first line of input contains a single integer $$$T$$$. Then, the descriptions of each of the $$$T$$$ test cases follows.
The first line of each test case contains the three space-separated integers $$$n$$$, $$$x$$$, and $$$y$$$.
Then, $$$n$$$ lines follow, each containing two space-separated values: the integer $$$K_i$$$, and the direction $$$dir_i$$$.
For each test case, if the task is possible, output a line containing the word YES. Otherwise, output NO.
If YES, also output $$$n$$$ lines containing the moves that should be made. Each line should contain two space separated values: the number of steps $$$k_i$$$, and the direction $$$d_i$$$.
If there are multiple possible answers, any will be accepted as long as they respect the strategy guide and return the gang to the ship.
$$$$$$\begin{align*}
&\begin{array}{|l|} \hline \text{Constraints For All Subtasks} \\ \hline 1 \leq T \\ 1 \leq n \\ \text{The sum of $n$ across all test cases is $\leq 2 \times 10^5$.} \\ |x|, |y| \leq 10^{15} \\ \text{$1 \leq K_i \leq 10^9$ for each $i$} \\ \hline \end{array}\\
&\begin{array}{|c|c|l|} \hline \text{Subtask} & \text{Points} & \text{Constraints} \\ \hline 1 & \mathbf{30} & n \leq 2 \\ \hline 2 & \mathbf{20} & n \leq 3 \\ \hline 3 & \mathbf{20} & \text{$n \leq 15$ and $T \leq 50$} \\ \hline 4 & \mathbf{30} & \text{No further constraints.} \\ \hline \end{array}\\
\end{align*}$$$$$$
2 3 -3 2 1 H 3 V 4 H 2 -100 -100 3 H 3 V
YES 1 E 2 S 2 E NO
These sample images correspond to the first of the test cases in the sample input.
| Название |
|---|


