#P2129. Delayed Military Orders
Delayed Military Orders
Delayed Military Orders
In country \(L\), the military is divided into \(n\) groups located on a Cartesian coordinate system with \(L\) as the origin. The command center issues \(m\) commands that affect the positions of these groups. There are three types of commands:
- MOVE: Move all groups by a vector \((dx, dy)\).
- VERTICAL: Shift all groups vertically by a value \(d\) (i.e. add \(d\) to the \(y\)-coordinate).
- HORIZONTAL: Shift all groups horizontally by a value \(d\) (i.e. add \(d\) to the \(x\)-coordinate).
However, due to communication delays, the commands are executed in reverse order (i.e. using a stack, process from the last command to the first). Your task is to compute the final coordinates of each group after all commands have been executed.
inputFormat
The first line contains two integers \(n\) and \(m\) separated by a space.
The next \(n\) lines each contain two integers \(x\) and \(y\) representing the initial coordinates of each group.
The following \(m\) lines each contain a command in one of the following formats:
MOVE dx dy
VERTICAL d
HORIZONTAL d
All numbers are integers.
outputFormat
Output \(n\) lines. For each group, output its final \(x\) and \(y\) coordinates separated by a single space.
sample
2 3
0 0
1 2
MOVE 1 1
VERTICAL 3
HORIZONTAL -2
-1 4
0 6
</p>