#P16054. [CSPro 31] 坐标变换(其一)

[CSPro 31] 坐标变换(其一)

Background

Luogu’s testdata is only for community communication and is not official testdata. Official judging link: https://www.cspro.org/.

Problem Description

For a point (x,y)(x, y) on the Cartesian plane, Little P defines a sequence T=(t1,t2,⋯ ,tn)T = (t_1, t_2, \cdots, t_n) consisting of nn operations. Each operation tit_i (1≤i≤n1 \le i \le n) has two parameters dxidx_i and dyidy_i, meaning translating the point (x,y)(x, y) to (x+dxi,y+dyi)(x + dx_i, y + dy_i).

Now given mm initial points, compute the final coordinates after applying the nn operations in TT in order to each point (xj,yj)(x_j, y_j) (1≤j≤m1 \le j \le m).

Input Format

Read input from standard input.

There are n+m+1n + m + 1 lines in total.

The first line contains two positive integers nn and mm separated by spaces, representing the number of operations and the number of initial points.

The next nn lines describe the nn operations in order. Line ii (1≤i≤n1 \le i \le n) contains two integers dxidx_i and dyidy_i separated by spaces.

The next mm lines describe the mm points in order. Line jj (1≤j≤m1 \le j \le m) contains two integers xjx_j and yjy_j separated by spaces.

Output Format

Output to standard output.

Output mm lines. Line jj (1≤j≤m1 \le j \le m) contains two integers separated by spaces, representing the position of the initial point (xj,yj)(x_j, y_j) after the nn operations.

3 2
10 10
0 0
10 -20
1 -1
0 0
21 -11
20 -10

Hint

Sample Explanation

After three operations, the first point (1,−1)(1, -1) becomes (21,−11)(21, -11); the second point (0,0)(0, 0) becomes (20,−10)(20, -10).

Subtasks

All testdata satisfies: n,m≤100n, m \le 100, and all input values (x,y,dx,dy)(x, y, dx, dy) are integers with absolute values not exceeding 10510^5.

Translated by ChatGPT 5