#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m, mx = 100000; cin >> n >> m; int th = 320, x, y; vector cnt(mx + 1); vector> cnt2(th, vector(th)); vector>> tb(mx + 2); //加える vector>> tb2(mx + 2); //削除 vector> tb3(mx + 2); //クエリ for(int i = 0; i < n; i++){ int l, r, x, y; cin >> l >> r >> x >> y; if(x < th){ tb[l].emplace_back(x, y); tb2[r + 1].emplace_back(x, y); }else{ while(y <= r){ if(y >= l) cnt[y]++; y += x; } } } vector b(m), ans(m); for(int i = 0; i < m; i++){ cin >> b[i]; tb3[b[i]].emplace_back(i); } for(int i = 0; i <= mx; i++){ for(auto &&pa : tb[i]){ tie(x, y) = pa; cnt2[x][y]++; } for(auto &&pa : tb2[i]){ tie(x, y) = pa; cnt2[x][y]--; } for(auto &&qi : tb3[i]){ for(int j = 1; j < th; j++){ ans[qi] += cnt2[j][i % j]; } } } for(int i = 0; i < m; i++){ ans[i] += cnt[b[i]]; cout << ans[i] << '\n'; } }