n,m = map(int,input().split()) lim = 200 M = 10**5 small = [[] for i in range(lim+1)] large = [] for i in range(n): l,r,x,y = map(int,input().split()) if x <= lim: small[x].append([y,l,r]) else: large.append([x,y,l,r]) A = list(map(int,input().split())) nums = [0]*M for x in range(1,lim+1): if small[x] == []: continue imos = [0]*M for y,l,r in small[x]: tl = l//x*x+y if tl < l: tl += x tr = (r+1)//x*x+y if tr <= r: tr += x # print(x,y,l,r,tl,tr) if tl < M: imos[tl] += 1 if tr < M: imos[tr] -= 1 for i in range(M): nums[i] += imos[i] if i+x < M: imos[i+x] += imos[i] for x,y,l,r in large: tl = l//x*x+y if tl < l: tl += x tr = (r+1)//x*x+y if tr <= r: tr += x tr = min(tr,M) for p in range(tl,tr,x): nums[p] += 1 for a in A: print(nums[a])