#include <iostream>
#include<cmath>
using namespace std;

int main() {
	// your code goes here
	int n,r;
	
	scanf("%d %d", &n, &r);
	
	int loc;
	scanf("%d", &loc);

	int xy[loc+1][2],i,j;
	
	for(i=0;i<loc; i++){
		scanf("%d %d" , &xy[i][0], &xy[i][1]);
	}
	
	int s;
	scanf("%d", &s);

	int xys[s+1][3];
	
	for(i=0;i<s;i++){
		scanf("%d %d %d", &xys[i][0], &xys[i][1], &xys[i][2]);
	}
	
	// precomputing distances
	
	float dist[loc+1][s+1];
	
	for(i=0; i < loc; i++){
		for(j=0; j <s; j++){
			float distx = abs(xys[j][0] - xy[i][0]);
			float disty = abs(xys[j][1] - xy[i][1]);
					
			float d = (distx*distx) + (disty*disty);
			d = sqrt(d);
			
			dist[i][j] = d;
					
		}
	}
	
	// consider all possible locations
	
	long int tot = 1<<loc;
	
	long int ans = 0;
	
	bool visit[s+1];
	
	// lest number with n set bits
	i = 1<<n;
	i -= 1;
	
	while(i < tot){
		
		int calc = 0;
		
		// check which locations are considered in i

		for(int l =0; l < s; l++)
			visit[l] = 0;
				
		
		for(j = 0; j < loc; j++ ){
			
			if( (i&(1<<j)) ){
				// we are considering j'th location
				
			for(int k = 0; k < s; k++){
					
				float d = dist[j][k];
				
				if( d <= r && visit[k] == 0){
				 		calc += xys[k][2];
						visit[k] = 1;
						//	cout<<k<<" ";
					}
				}
			}
		}
		
	//	cout<<"Total : "<<calc<<endl;
		if( ans < calc )
			ans = calc;
			
		// find the next higher number with same number of set bits
		int right = i&(-i);
		int next = i+right;
		int op = (i^next);
		op = op/right;
		op>>=2;
		i = next|op;
		
	}
	
	printf("%d\n",ans);
	
	return 0;
}