시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 4 2 2 66.667%

문제

Picko는 피자집을 열려고한다. 생각해뒀던 몇 개의 점포가 있는데, 그 중 가게가 흥할 것만 같은 점포들을 몇개 알아두었다. 한 점포에 피자집을 열게되면, 그 피자집에서 주어진 범위 내의 모든 가구들에게 배달을 갈 수 있다.

Picko가 열 수 있는 피자집의 수는 제한이 되어 있다. 한 가구당 임의 S명의 사람들이 살고 있는데, 최적의 점포들에 입점을 해 배달 가능한 최대 사람의 수를 구하라.

입력

첫째 줄에는 정수 피잣집의 수 K(1 ≤ K ≤ 10)와 각 지점이 배달할 수 있는 최대 거리 R(1 ≤ R ≤ 500)이 주어진다.

둘째 줄에는 정수 Picko가 알아둔 점포의 수 M(K ≤ M ≤ 20)이 주어진다.

이어지는 M줄에는 각 점포의 좌표를 가리키는 정수 X와Y가 주어진다.(-1000 ≤ X,Y ≤ 1000)

그 다음 줄에는 가구의 수 N(1 ≤ N ≤ 100)이 주어진다.

이어지는 N줄에는 각 가구의 좌표 X, Y(-1000 ≤ X,Y ≤ 1000)와 몇 인 가구인지 가리키는 정수 S(1 ≤ S ≤ 100)가 주어진다.

가구로부터 점포까지의 거리가 주어진 R보다 작거나 같다면 그 가구내의 모든 사람들에게 배달이 가능하다.

출력

K개의 피잣집으로 배달 가능한 최대 사람 수를 구하라. (가구의 수가 아니다!!)

예제 입력 1

2 2
3
1 0
4 0
7 0
4
0 0 1
3 0 7
5 0 9
8 0 1

예제 출력 1

18

예제 입력 2

2 2
3
-2 0
0 1
3 0
8
-3 1 1
-3 0 1
-3 -1 1
-2 -1 1
0 0 3
0 2 1
2 1 3
4 0 2

예제 출력 2

12

예제 입력 3

3 3
5
0 0
1 6
2 3
6 6
7 2
8
0 1 2
0 5 3
0 6 1
1 0 1
3 2 3
3 6 2
6 2 4
8 6 3

예제 출력 3

17

힌트

W3sicHJvYmxlbV9pZCI6IjMyMjgiLCJwcm9ibGVtX2xhbmciOiIwIiwid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