#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<30;

int n,m;
struct Cat {
  int x,y,C;
  Cat() {}
  Cat(int x, int C) :x(x),C(C) {}
  bool operator<(const Cat &b) const {
    return x != b.x ? x<b.x : C<b.C;
  }
} cat[1000];
int X[1000];
int dp[1000];
int sum[1001];
int numL[1000][1000];
int numR[1000][1000];

bool ok(int k) {
  REP(i,m) dp[i] = INF;
  int c = upper_bound(cat,cat+n,Cat(X[m-1],INF))-cat;
  dp[m-1] = sum[n]-sum[c];
  for (int i=m-1; i>=0; --i) {
    for (int j=i+1; j<m; ++j) {
      if (numR[i][j]+dp[j] <= k)
        chmin(dp[i], numL[i][j]);
    }
    int a = upper_bound(cat,cat+n,Cat(X[i],INF))-cat;
    if (dp[i] + sum[a] <= k) return 1;
  }
  return 0;
}

int main() {
  while(cin>>n>>m,n||m) {
    REP(i,n) cin>>cat[i].x>>cat[i].y>>cat[i].C;
    sort(cat,cat+n);
    REP(i,m) cin>>X[i];
    sort(X,X+m);
    REP(i,n) {
      sum[i+1] = sum[i] + cat[i].C;
    }
    // int id=0;
    // REP(i,m) {
    //   while(id<n && cat[id].x<=X[i]) id++;
    //   sum2[i] = sum[id];
    // }
    for (int i=0; i<m-1; ++i) {
      for (int j=i+1; j<m; ++j) {
        int a = upper_bound(cat,cat+n,Cat(X[i],INF))-cat;
        int mid = (X[i]+X[j])/2;
        if (X[i]+X[j]<0) mid = (X[i]+X[j]-1)/2;
        int b = upper_bound(cat,cat+n,Cat(mid,INF))-cat;
        int c = upper_bound(cat,cat+n,Cat(X[j],INF))-cat;
        numL[i][j] = sum[b]-sum[a];
        numR[i][j] = sum[c]-sum[b];
        // cout << i << " " << j << " " << numL[i][j] << " " << numR[i][j] << endl;
      }
    }
    int low=-1,high=INF;
    while(low+1<high) {
      int mid = (low+high)/2;
      if (ok(mid)) high = mid;
      else low = mid;
    }
    cout << high << endl;
  }
}