Crane Delivery

Time limit1sMemory limit128 MB

Problem

A construction site is a rectangle in the coordinate plane whose sides are parallel to the coordinate axes. One corner is at (0, 0), and the opposite corner is at (X, Y).

The entrance to the site is at the midpoint of the bottom side, namely (X/2, 0). There are N cranes on the site. Each crane is fixed at one point, can rotate 360 degrees, and has a known maximum reach.

A truck unloads heavy equipment at the entrance. The equipment is then moved through a sequence of crane operations. In one operation, a crane can pick up the equipment from its current position and place it at any point within that crane's maximum reach.

Given K destinations inside the site, determine for each destination whether the equipment can be delivered there.

Input

The first line contains two integers X and Y. 2 <= X, Y <= 200, and X is even.

The second line contains an integer N, the number of cranes. 1 <= N <= 50.

Each of the next N lines contains three integers A, B, and C. The crane is located at (A, B), and its maximum reach is C. 0 <= A <= X, 0 <= B <= Y, and 0 <= C <= 200.

The next line contains an integer K, the number of destinations. 3 <= K <= 30.

Each of the next K lines contains two integers D and E. The destination is located at (D, E), where 0 <= D <= X and 0 <= E <= Y.

Output

For each destination, print one line containing DA or NE. DA means the equipment can be delivered to that destination, and NE means it cannot.