grad | 프로그래밍의 벗 PivotOJ
PivotOJ

grad

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2006 National Competition #2 - SeniorsBOJ 3170
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

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. 

[이미지 1]

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. 

입력

The 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 C – (A,B) is the position of the crane, and C is its maximum reach, 0 ≤ A ≤ X, 0 ≤ B ≤ Y, 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 ≤ D ≤ X, 0 ≤ E ≤ Y. 

출력

Each 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. 

예제

예제 1

입력
4 4
2
2 1 1
2 3 1
4
2 2
3 2
1 2
2 3
출력
DA
NE
NE
DA

예제 2

입력
6 10
3
3 3 2
6 0 3
0 8 5
5
4 1
2 4
4 10
5 10
5 9
출력
DA
DA
DA
NE
NE

예제 3

입력
8 5
4
2 1 3
4 5 1
6 4 1
5 2 2
5
0 2
0 3
4 4
7 4
7 5
출력
DA
DA
NE
DA
NE
코드를 제출하려면 로그인하세요.