typedef long long ll; typedef long double ld; #include using namespace std; #define int long long signed main(){ ll n,m; std::cin >> n>>m; vector> q(n); for (int i = 0; i < n; i++) { ll l,r,x,y; std::cin >> l>>r>>x>>y; q[i] = {l,r,x,y}; } vector a(m); for (int i = 0; i < m; i++) { std::cin >> a[i]; } vector ans(100001); vector> imos(100003,vector(320)); for (int i = 0; i < n; i++) { auto [l,r,x,y] = q[i]; if(x>=320){ while(y<=100000){ if(l<=y&&y<=r){ ans[y]++; } y+= x; } continue; } ll st = max(0ll, (l-y+x-1)/x*x+y); ll en = min(100000ll, (r-y)/x*x+y); if(st=0)imos[j][i] += imos[j-i][i]; } } for (int j = 1; j <= 100000; j++) { for (int i = 1; i < 320; i++) { ans[j] += imos[j][i]; } } for (int i = 0; i < m; i++) { std::cout << ans[a[i]] << std::endl; } }