Rotating Line

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Consider an infinite two-dimensional plane. There are nn fixed points and one rotating line given on the plane. One of the points is (0,0)(0, 0), the origin, and the line initially coincides with the yy axis. The points are distinct, but it is not guaranteed that no three points lie on a same line.

The line is being rotated in counter-clockwise direction. The centre of rotation is always one of the nn given points, initially the origin, but it may change. Specifically, as long as the line contains only one point, the rotation centre is this point. As soon as the line meets another point, consider all given points currently lying on our line, ordered as pairs of coordinates (x,y)(x, y). If there are kk points on the line, and the current rotation centre is the pp-th of them, counting from 11, the next rotation centre will be the (kp+1(k - p + 1)-th of these points. If p=kp+1p = k - p + 1, the rotation centre does not change. Initially, the line starts rotating even if there are several given points on it.

Your task is to find the qq-th rotation centre. The initial centre is numbered by 00, and as long as the centre does not change, the counter does not increase. Nevertheless, it is guaranteed that, for the given set of points, the qq-th rotation centre exists.

입력

The first line of input contains an integer nn, the number of points (2n30002 \le n \le 3000).

The ii-th line of the following nn lines contains two integers xx and yy, the coordinates of the ii-th point (100x,y100-100 \le x, y \le 100). It is guaranteed that one of these points is (0,0)(0, 0). The points are distinct, but it is not guaranteed that no three points lie on a same line.

The next line contains an integer QQ, the number of queries (1Q27001 \le Q \le 2700). Then follow QQ lines, each contains a single integer q_iq\_i (0<q_i1090 < q\_i \le 10^9). It is guaranteed that the queries are given in strictly ascending order.

출력

Prine QQ lines, one for each query. Each line must contain a pair of integers: the coordinates of q_iq\_i-th rotation centre.

힌트

The initial rotation centre (numbered as 00) is (0,0)(0, 0). The rotation centre number 11 is (1,2)(-1, 2), because this is the point which the line meets first.

Then the line meets two points (0,1)(0, 1) and (1,0)(1, 0) simultaneously, so that there are three points on the line. (1,2)(-1, 2) is the first of them in sorted order, so the centre has to change to the third point, which is (1,0)(1, 0). Thus, (1,0)(1, 0) is the rotation centre number 22.

Then the line meets three points (1,0)(-1, 0), (0,0)(0, 0), and (2,0)(2, 0), so that there are four points on the line. The centre is the third of them in sorted order, so the centre number 33 will be the second of the four points, (0,0)(0, 0).

Similarly, we can show that the 44-th rotation centre will be (0,1)(0, 1).

After that, the line meets two points (1,2)(-1, 2) and (1,0)(1, 0). The centre is the second point out of three in sorted order, so it does not change.

After that, the line meets (2,0)(2, 0), so the 55-th rotation centre is (2,0)(2, 0).