from collections import * from itertools import * from functools import * from heapq import * import sys, math input = sys.stdin.readline class hopping_cumsum: def __init__(self, X, Mod): self.Mod = Mod self.X = X self.N = len(X) self.T = [0] * Mod + X for i in range(self.N): self.T[i + Mod] = self.T[i] + self.T[i + Mod] def query(self, l, r, k): # x in [l,r), x=k(mod Mod)の和 L = l + (k - l) % self.Mod R = r + (k - r) % self.Mod return self.T[R] - self.T[L] class hopping_imos: def __init__(self, N, Mod): self.N = N self.Mod = Mod self.X = [0] * (N + Mod) def add(self, l, r, a, k): # x in [l,r), x=k(mod Mod)にaを加える L = l + (k - l) % self.Mod R = r + (k - r) % self.Mod if L < self.N: self.X[L] += a if R < self.N: self.X[R] -= a def build(self): for i in range(self.N): self.X[i + self.Mod] = self.X[i + self.Mod] + self.X[i] def query(self, idx): return self.X[idx] M, _ = map(int, input().split()) N = 10**5 + 1 B = 300 T = [0] * (N + 1) U = [hopping_imos(N + 1, i) for i in range(B)] for _ in range(M): l, r, x, y = map(int, input().split()) if x < B: U[x].add(l, r + 1, 1, y) else: L = l + (y - l) % x for i in range(L, r + 1, x): T[i] += 1 for i in range(B): U[i].build() A = list(map(int, input().split())) for a in A: print(T[a] + sum(U[i].query(a) for i in range(B))) # for i in range(1, 4): # print(U[i].X[:10])