import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(1000005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 md = 10**9+7 # md = 998244353 from heapq import * from collections import defaultdict, Counter mx = 100000 sq = 200 n, m = LI() lrxy = LLI(n) aa = LI() ja = sorted(enumerate(aa), key=lambda x: x[1]) lrxy.sort(key=lambda x: -x[0]) ans = [0]*m xtoy = defaultdict(Counter) cnt = [0]*(mx+1) hp = [] for j, a in ja: while lrxy and lrxy[-1][0] <= a: l, r, x, y = lrxy.pop() if x < sq: xtoy[x][y] += 1 else: for i in range(y, mx+1, x): cnt[i] += 1 heappush(hp, (r, x, y)) while hp and hp[0][0] < a: r, x, y = heappop(hp) if x < sq: xtoy[x][y] -= 1 if xtoy[x][y] == 0: del xtoy[x][y] if not xtoy[x]:del xtoy[x] else: for i in range(y, mx+1, x): cnt[i] -= 1 ans[j] = cnt[a] for x in xtoy: b = a%x if b in xtoy[x]: ans[j] += xtoy[x][b] print(*ans,sep="\n")