from collections import defaultdict n,m = map(int,input().split()) xylr = defaultdict(list) for _ in range(n): l,r,x,y = map(int,input().split()) xylr[(x,y)].append((l,r)) z = 10**5; a = [0]*(z+1) for (x,y),lr in xylr.items(): d = {}; mi = z; ma = 0 for l,r in lr: p = l+(y-l%x)%x; q = r+1+(y-(r+1)%x)%x mi = min(mi,p); ma = max(ma,q) if p<=z: d[p] = d.get(p,0)+1 if q<=z: d[q] = d.get(q,0)-1 i = mi while i<=min(ma,z)-x: d[i+x] = d.get(i+x,0)+d[i]; i += x for k,v in d.items(): a[k] += v for v in map(int,input().split()): print(a[v])