#P2129. L 国的战斗续之多路出击

L 国的战斗续之多路出击

Description

This time, Country L decides to divide its army into nn groups distributed across various locations. Taking Country L as the origin, these positions can be viewed in a Cartesian coordinate system. All groups are under unified command, and the command center issues mm commands. Commands include translation, up-down flip, and left-right flip. However, due to some odd latency, the army always receives commands with a delay. For convenience, a stack has already been prepared, so you must process the commands from back to front.

Input Format

The input consists of n+m+1n+m+1 lines.

The first line contains two integers n,mn, m.

The next nn lines: on the (i+1)(i+1)-th line, two integers xi,yix_i, y_i give the location of the ii-th army group.

The next mm lines each start with a character cc.

  • If cc is m, then two integers p,qp, q follow, meaning every group moves from (xi,yi)(x_i, y_i) to (xi+p,yi+q)(x_i + p, y_i + q).
  • If cc is x, then every group moves from (xi,yi)(x_i, y_i) to (xi,yi)(-x_i, y_i) (left-right flip, i.e., reflection across the yy-axis).
  • If cc is y, then every group moves from (xi,yi)(x_i, y_i) to (xi,yi)(x_i, -y_i) (up-down flip, i.e., reflection across the xx-axis).

Output Format

Output nn lines. On the ii-th line, print two integers xi,yix_i', y_i', the final position of the ii-th army group after all commands are applied (processed from last to first).

3 3
0 0
4 -3
6 7
x
m -1 2
y

1 2
-3 5
-5 -5

Hint

For 30%30\% of the testdata, 1n,m10001 \leqslant n, m \leqslant 1000.

For 100%100\% of the testdata, 1n,m5×1051 \leqslant n, m \leqslant 5 \times 10^5, and xi,yix_i, y_i are within the int range.

Translated by ChatGPT 5