#include using namespace std; using pii = pair; const int N = 1e5 + 10, B = 350; int sc[B][B], lc[B]; int n, m, ans[N]; vector s[N]; vector q[N]; int main() { cin >> n >> m; for(int i = 1, l, r, x, y; i <= n; i ++) { cin >> l >> r >> x >> y; s[l].push_back({x, y}); s[r + 1].push_back({-x, y}); } for(int i = 1, x; i <= m; i ++) { cin >> x; q[x].push_back(i); } for(int i = 1; i < N; i ++) { for(auto [p, x] : s[i]) { int w = 1; if(p < 0) { p = -p; w = -w; } if(p < B) sc[p][x] += w; else{ for(int i = 0; i * p + x < N; i ++) lc[i * p + x] += w; } } if(q[i].empty()) continue; int tot = lc[i]; for(int j = 1; j < B; j ++) tot += sc[j][i % j]; for(auto x : q[i]) { ans[x] = tot; } } for(int i = 1; i <= m; i ++) cout << ans[i] << "\n"; }