#pragma GCC target("avx2") #pragma GCC optimize("Ofast,unroll-loops") #include int main() { int i, j, N, M, L, R, X, Y, A, ans[100001] = {}; scanf("%d %d", &N, &M); for (i = 1; i <= N; i++) { scanf("%d %d %d %d", &L, &R, &X, &Y); for (j = (L - Y + X - 1) / X * X + Y; j <= R; j += X) ans[j]++; } for (i = 1; i <= M; i++) { scanf("%d", &A); printf("%d\n", ans[A]); } fflush(stdout); return 0; }