Intelligent Robots

No attempts yetTime limit1sMemory limit128 MB

Problem

We have a robot and an obstacle in a 2-dimensional plane. The robot is an axis-aligned (rectilinear) square, and the obstacle is a rectilinear polygon, meaning every edge is either horizontal or vertical. Initially the robot lies completely outside the obstacle: it does not touch the boundary and is not in the interior.

The robot wants to escape the obstacle by translating in horizontal or vertical directions without ever intersecting it. The robot has escaped once it lies completely outside the smallest axis-aligned rectangle that contains the obstacle (see Figure 1 and Figure 2). The robot may already start outside that rectangle.

In Figure 1 the robot cannot escape, but in Figure 2 it can. RR marks the robot and PP marks the obstacle. Let (x,y)(x, y) be a vertex of PP; then xx and yy are both multiples of 1010 with 10x,y1,000,00010 \le x, y \le 1{,}000{,}000. The side length of RR is a natural number below 1,000,0001{,}000{,}000 whose last digit is always 22 (for example 2,12,22,32,2, 12, 22, 32, \dots).

Figure 1

Figure 2

Write a program that decides whether the robot can escape the obstacle.

Input

The first line contains the number of test cases TT.

Each test case is given as follows. The first line contains three integers nxn_x, nyn_y, and ww (2nx,ny,w1,000,0002 \le n_x, n_y, w \le 1{,}000{,}000), where (nx,ny)(n_x, n_y) is the bottom-left corner of the robot RR and ww is its side length, whose last digit is always 22. The second line contains an integer nn (4n1,0004 \le n \le 1{,}000), the number of vertices of the rectilinear polygon PP. Each of the next nn lines gives one vertex of PP in counterclockwise order as two integers xx and yy (10x,y1,000,00010 \le x, y \le 1{,}000{,}000, both multiples of 1010). In every test case the robot starts outside PP.

Output

For each test case, print YES on its own line if the robot can escape the obstacle, or NO otherwise.