#000329

Grad

A construction site is defined as a rectangle in the coordinate system with sides parallel to the coordinate axes, with one corner in (0,0) and the opposite corner in (X,Y). The entrance to the site is in the middle of the bottom side. There are N cranes on the construction site. Each crane is situated in a point on the site, it can rotate 360 degrees and the maximum reach is known for each crane. The truck unloads heavy equipment on the entrance of the site and after that the equipment is carried across the site by a sequence of crane movements. In each step, one crane picks up the equipment and leaves it at any place within the maximum reach of that crane.

Image: dsadsa
Write a program that, given a list of K destinations within the site, determines for each destination if it is possible to carry the equipment to this destination.


InputThe first line of input contains two integers X and Y, 2 ≤ X,Y ≤ 200, X is even. Next line contains an integer N, 1 ≤ N ≤ 50, the number of cranes. Each of the following N lines contains three integers A, B and [] – (A,B) is the position of the crane, and C is its maximum reach, 0 ≤ AX, 0 ≤ BY, 0 ≤ C ≤ 200. The next line contains an integer K, 3 ≤ K ≤ 30, the number of destinations. Each of the following N lines contains two integers D and E(D,E) is the position of one destination,
0 ≤ DX, 0 ≤ EY.

OutputEach of the K lines should contain the word 'DA' or 'NE' – 'DA' means that it is possible to deliver the equipment to that destination, and 'NE' means that it is not possible.

Input
[c]4 4
2
2 1 1
2 3 1
4
2 2
3 2
1 2
2 3

Output
DA
NE
NE
DA

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.