n, m = map(int, input().split()) dic = {} for _ in range(n): l, r, x, y = map(int, input().split()) tmp = (x << 20) | y dic.setdefault(tmp, []).append((l, r)) A = list(map(int, input().split())) ma = max(A) cnt = [0] * (ma + 1) for key, lst in dic.items(): x = key >> 20 y = key & 0xFFFFF le = ma // x imos = [0] * (le + 5) for l, r in lst: s = (l - y + x - 1) // x t = (r - y) // x imos[s] += 1 imos[t + 1] -= 1 for i in range(le + 4): imos[i + 1] += imos[i] if i * x + y <= ma: cnt[i * x + y] += imos[i] else: break for a in A: print(cnt[a])