from collections import defaultdict import math # xで割ったあまりがyになる自然数の中で、n以上で最小のものを返す関数 def f(n, x, y): mo = n % x if mo <= y: return n + y - mo else: return n + x + y - mo # xで割ったあまりがyになる自然数の中で、n以下で最大のものを返す関数 def g(n, x, y): mo = n % x if y <= mo: return n + y - mo else: return n - x + y - mo N, M = map(int, input().split()) sq = math.isqrt(10 ** 5) higher = [] lower = [[] for _ in range(sq)] for _ in range(N): l, r, x, y = map(int, input().split()) if x < sq: lower[x].append((y, l, r)) else: higher.append((l, r, x, y)) line = [0] * (10 ** 5 + 1) for l, r, x, y in higher: start = f(l, x, y) end = g(r, x, y) for i in range(start, end + 1, x): line[i] += 1 for x, gr in enumerate(lower): x_line = [0] * (10 ** 5 + 1) for y, l, r in gr: start = f(l, x, y) end = g(r, x, y) + x x_line[start] += 1 try: x_line[end] -= 1 except IndexError: pass for i in range(x, 10 ** 5 + 1): x_line[i] += x_line[i - x] for i in range(10 ** 5 + 1): line[i] += x_line[i] A = list(map(int, input().split())) for a in A: print(line[a])