#include <iostream>
#include<vector>
#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
	
	vector<int> vec[loc+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);
			
			if( d <= r){
				vec[i].push_back(j);
			}
		}
	}
	
	// consider all possible locations
	
	long int tot = 1<<loc;
	
	long int ans = 0;
	
	bool visit[s+1];
	
	// least number with n set bits
	i = 1<<n;
	i -= 1;
	
	while(i < tot){
		
		int calc = 0;
		
		for(j=0;j<s; j++)
			visit[j] = 0;
		
		for(j = 0; j < loc; j++ ){
			
			if( (i&(1<<j)) ){
				// we are considering j'th location
				
				for(int k = 0; k< vec[j].size(); k++ ){
					if( visit[vec[j][k]] == 0){
						calc += xys[vec[j][k]][2];
						visit[vec[j][k]] = 1;
					}
				}
				
			}
		}
		
	//	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;
}