from sys import stdin input = stdin.readline shikii = 100 N, M = map(int, input().split()) query = [list(map(int, input().split())) for _ in range(N)] A = list(map(int, input().split())) Q = [[] for _ in range(shikii+1)] C = [0]*(10**5+1) for L, R, X, Y in query: if X <= 100: Q[X].append((L, 0, Y)) Q[X].append((R+1, 1, Y)) else: for i in range(Y, 10**5+1, X): if L <= i <= R: C[i] += 1 for i in range(1, shikii+1): cnt = [0]*i Q[i].sort(key=lambda x:x[0]) idx = 0 for j in range(1, 10**5+1): while idx < len(Q[i]) and Q[i][idx][0] == j: if Q[i][idx][1] == 0: cnt[Q[i][idx][2]] += 1 else: cnt[Q[i][idx][2]] -= 1 idx += 1 C[j] += cnt[j%i] print(*[C[a] for a in A], sep="\n")