import sys input = sys.stdin.readline n, m = map(int, input().split()) inf = 10 ** 5 + 1 s_inf = 316 pl = [[0 for i in range(inf)] for j in range(s_inf)] a = [0 for i in range(inf)] for _ in range(n): l, r, x, y = map(int, input().split()) l = (l - y + x - 1) // x * x + y r = (r - y + x) // x * x + y if x < s_inf: pl[x][l] += 1 if r < inf: pl[x][r] -= 1 else: while l < r: a[l] += 1 l += x for x in range(1, s_inf): for y in range(x, inf): pl[x][y] += pl[x][y - x] for y in range(inf): a[y] += pl[x][y] for i in list(map(int, input().split())): print(a[i])