#include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template ostream& operator<<(ostream &os, const pair &p) { return os << '(' << p.first << ", " << p.second << ')'; } template::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector vi; typedef vector vvi; typedef pair pi; const int mxN = 1e5+1, oo = 1e9; const int B = 240; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin >> n >> m; // have some of those? vector> arr(n); for(auto& [l,r,x,y] : arr) { cin >> l >> r >> x >> y; int k = (l-y+x-1)/x; l = k*x+y; if(rr) { l=-1,r=-1,x=-1,y=-1; } } vi a(m); for(auto& i : a) { cin >> i; } // only ones that have x very small are bad. vi ans(m); for(int x=1;x<=B;++x) { vi p(mxN+B+1); for(auto [l,r,xx,y] : arr) { if(x==xx) { p[l]+=1; p[r+x]-=1; } } for(int i=x;iB) { for(int i=l;i<=r;i+=x) { cnt[i]+=1; } } } for(int i=0;i