#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i(0);i^n;++i)
#define N 200010
int Q,m,n,q,x[N],y[N],t[N],f[N],v[N],p[N],o[N];
bool cmp(const int i,const int j){return t[i]<t[j];}
int get(int x){return f[x]==x?x:f[x]=get(f[x]);}
int main(){
ios::sync_with_stdio(false);
cin>>Q>>m;
fo(i,m)cin>>x[i]>>y[i]>>t[i],v[n++]=x[i],v[n++]=y[i],p[i]=i;
sort(v,v+n),n=unique(v,v+n)-v,sort(p,p+m,cmp);
fo(i,n+1)f[i]=i,o[i]=-1;
fo(k,m){
int i=p[k],l=lower_bound(v,v+n,x[i])-v,r=lower_bound(v,v+n,y[i])-v;
for(int j=get(l);j<r;j=get(j))o[j]=t[i],f[j]=j+1;
}
m=0;if(*o>=0)t[m++]=*o-*v;
fo(i,n-1)if(o[i]!=o[i+1]){
if(o[i]>=0)t[m++]=o[i]-v[i+1];
if(o[i+1]>=0)t[m++]=o[i+1]-v[i+1];
}
fo(i,m)p[i]=i;
sort(p,p+m,cmp);
int j=0,k=0,s=0,T=0;
fo(i,Q){
for(cin>>q;j<m&&t[p[j]]<=q;++j)s+=k*(T-t[p[j]]),T=t[p[j]],k+=p[j]&1?-1:1;
s+=k*(T-q),T=q,cout<<s<<endl;
}
return 0;
}
144. Binary Tree Preorder Traversal | 137. Single Number II |
130. Surrounded Regions | 129. Sum Root to Leaf Numbers |
120. Triangle | 102. Binary Tree Level Order Traversal |
96. Unique Binary Search Trees | 75. Sort Colors |
74. Search a 2D Matrix | 71. Simplify Path |
62. Unique Paths | 50. Pow(x, n) |
43. Multiply Strings | 34. Find First and Last Position of Element in Sorted Array |
33. Search in Rotated Sorted Array | 17. Letter Combinations of a Phone Number |
5. Longest Palindromic Substring | 3. Longest Substring Without Repeating Characters |
1312. Minimum Insertion Steps to Make a String Palindrome | 1092. Shortest Common Supersequence |
1044. Longest Duplicate Substring | 1032. Stream of Characters |
987. Vertical Order Traversal of a Binary Tree | 952. Largest Component Size by Common Factor |
212. Word Search II | 174. Dungeon Game |
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |