//BinarySearch + DynamicProgramming
//
#include<iostream>
#include<cassert>
#include<cstdlib>
#include<algorithm>
#include<numeric>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef long long ll;
const int N = 1000;
int adj[N][N];
int r[N];

int bestpoint(int n,int *esa,int l,int y,int x,ll tdist){
  int r=n-1;
  int ret=-1;
  if (esa[r] < x)return r;
  while(l <= r){
    int mid=(l+r)/2;
    ll mdist=esa[mid]-x;
    assert(mdist >= 0);
    if (mdist < tdist){
      ret=mid;
      l=mid+1;
    }else {
      r=mid-1;
    }
  }
  return ret;
}

void setdata(int n,int *esa,int m,int *y,int *x,int *num){
  rep(i,n){
    REP(j,i+1,n)adj[i][j]=0;
    rep(j,m){
      if (esa[i] < x[j]){
	ll tdist=llabs(esa[i]-x[j]);
	int ind=bestpoint(n,esa,r[j],y[j],x[j],tdist);
	//cout <<"check " << i <<" " << j <<" : " << esa[i] <<" " << x[j] << " " << ind << endl;
	if (ind == -1)ind=r[j]-1;
	if (ind >= 0)adj[i][ind]+=num[j];
      }
    }
    for(int j=n-2;j>i;j--){
      adj[i][j]+=adj[i][j+1];
    }

    /*
    for(int k=m-1;k>=0;k--){
      ll tmp=llabs(esa[i]-x[k]);
      REP(j,i+1,n){
	if (tmp > llabs(esa[j]-x[k]))adj[i][j]+=num[k];
      }
    }
    */
  }
}

int dp[N];
bool isok(int n,int lim,int total){
  rep(i,n){
    dp[i]=total;
    rep(j,i){
      if (dp[j]-adj[j][i] > lim)continue;
      dp[i]=min(dp[i],adj[j][i]);
    }
  }
  rep(i,n)if (dp[i] <= lim)return true;
  return false;
}

int solve(int n,int total){
  int l=0,r=total;
  int ret=total;
  while(l <= r){
    int mid=(l+r)/2;
    if (isok(n,mid,total))ret=mid,r=mid-1;
    else l=mid+1;
  }
  return ret;
}

int main(){
  int n,m;
  static int x[N],y[N],num[N],esa[N];
  while(cin>>m>>n){
    if (m == 0 && n == 0)break;
    int total=0;
    rep(i,m)cin>>x[i]>>y[i]>>num[i],total+=num[i];
    rep(i,n)cin>>esa[i];
    sort(esa,esa+n);
    rep(i,m){
      r[i]=n-1;
      for(int j=n-1;j>=0;j--){
	if (x[i] <= esa[j] )r[i]=j;
      }
    }
    setdata(n,esa,m,y,x,num);
    //int total=accumulate(num,num+m,0);
    cout << solve(n,total) << endl;
  }
  return false;
}