#include using namespace std; #ifdef LOCAL #include "debug.hpp" #else #define debug(...) 1 #endif const int MAX = 100000 + 5; const int B = 340; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector> A(B, vector(MAX, 0)); vector cnt(MAX, 0); vector C(m); for (int i = 0; i < n; i++) { int L, R, X, Y; cin >> L >> R >> X >> Y; int vl = L / X * X + Y; while (vl < L) vl += X; while (vl - X >= L) vl -= X; int vr = R / X * X + Y; while (vr > R) vr -= X; while (vr + X <= R) vr += X; if (X < B) { A[X][vl]++; if (vr + X <= MAX) { A[X][vr + X]--; } } else { for (int j = vl; j <= vr; j += X) { cnt[j]++; } } } for (int i = 0; i < m; i++) { cin >> C[i]; } for (int i = 1; i < B; i++) { for (int j = 0; j < MAX; j++) { if (j + i < MAX) { A[i][j + i] += A[i][j]; } } for (int j = 0; j < MAX; j++) { cnt[j] += A[i][j]; } } for (int i = 0; i < m; i++) { cout << cnt[C[i]] << '\n'; } }