#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1005

struct Info{

	bool operator<(const struct Info &arg) const{

		return x < arg.x;
	}
	int x,y,num;
};

int N,M;
int X[SIZE],SUM[SIZE];
int table_L[SIZE][SIZE],table_R[SIZE][SIZE];
int dp[SIZE];
Info info[SIZE];


bool isOK(int num){

	for(int i = 0; i < M; i++){

		dp[i] = BIG_NUM;
	}

	int l,r,mid;

	if(info[N-1].x < X[M-1]){

		dp[M-1] = 0;
	}else{

		l = 0,r = N-1,mid = (l+r)/2;
		int L = r;

		while(l <= r){

			if(info[mid].x >= X[M-1]){

				L = mid;
				r = mid-1; //より左へ
			}else{

				l = mid+1;
			}
			mid = (l+r)/2;
		}

		if(L == 0){

			dp[M-1] = SUM[N-1];

		}else{

			dp[M-1] = SUM[N-1]-SUM[L-1];
		}
		if(dp[M-1] > num){

			return false;
		}
	}

	int R;

	for(int i = M-1; i >= 0; i--){
		for(int k = i+1; k < M; k++){
			if(dp[k]+table_R[i][k] > num)continue;

			dp[i] = min(dp[i],table_L[i][k]);
		}

		if(dp[i] > num)continue;

		if(info[0].x > X[i]){

			return true;
		}

		l = 0,r = N-1,mid = (l+r)/2;
		R = 0;

		while(l <= r){

			if(info[mid].x < X[i]){

				R = mid;
				l = mid+1;
			}else{

				r = mid-1;
			}
			mid = (l+r)/2;
		}

		if(SUM[R]+dp[i] <= num){

			return true;
		}
	}

	return false;
}


void func(){

	int total = 0;

	for(int i = 0; i < N; i++){

		scanf("%d %d %d",&info[i].x,&info[i].y,&info[i].num);
		total += info[i].num;
	}

	for(int i = 0; i < M; i++){

		scanf("%d",&X[i]);
	}

	sort(info,info+N);

	SUM[0] = info[0].num;
	for(int i = 1; i < N; i++){

		SUM[i] = SUM[i-1]+info[i].num;
	}

	sort(X,X+M);

	int L,R;
	int l,r,mid;
	int MID,center;

	for(int left = 0; left < M-1; left++){
		for(int right = left+1; right < M; right++){

			if(info[N-1].x < X[left] || info[0].x >= X[right]){
				table_L[left][right] = 0;
				table_R[left][right] = 0;
				continue;
			}

			l = 0,r = N-1,mid = (l+r)/2;
			L = r;

			while(l <= r){

				if(info[mid].x >= X[left]){

					L = mid;
					r = mid-1;
				}else{

					l = mid+1;
				}
				mid = (l+r)/2;
			}

			l = 0,r = N-1,mid=(l+r)/2;
			R = 0;

			while(l <= r){

				if(info[mid].x < X[right]){

					R = mid;
					l = mid+1;
				}else{

					r = mid-1;
				}
				mid = (l+r)/2;
			}

			if(L > R){

				table_L[left][right] = 0;
				table_R[left][right] = 0;
				continue;
			}
			MID = (X[left]+X[right])/2;

			if(X[right]-MID < MID-X[left]){

				MID--;
			}

			l = L,r = R,mid = (l+r)/2;
			center = -1;
			while(l <= r){
				if(info[mid].x <= MID){

					center = mid;
					l = mid+1;
				}else{

					r = mid-1;
				}
				mid = (l+r)/2;
			}

			if(center == -1){

				table_L[left][right] = 0;
				if(L == 0){

					table_R[left][right] = SUM[R];

				}else{

					table_R[left][right] = SUM[R]-SUM[L-1];
				}
				continue;
			}

			table_R[left][right] = SUM[R]-SUM[center];

			if(L == 0){

				table_L[left][right] = SUM[center];
			}else{

				table_L[left][right] = SUM[center]-SUM[L-1];
			}
		}
	}

	l = 0,r = total,mid = (l+r)/2;
	int ans = r;

	while(l <= r){
		if(isOK(mid)){

			ans = mid;
			r = mid-1;

		}else{

			l = mid+1;
		}
		mid = (l+r)/2;
	}

	printf("%d\n",ans);
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 11008