#include using namespace std; using ll = long long; template T ceil(T a, T b){ assert(b != 0); if (a == 0) return 0; if (a > 0 && b > 0) return (a+b-1) / b; else if (a < 0 && b < 0) return (a+b+1) / b; else return a / b; } template T floor(T a, T b){ assert(b != 0); if (a == 0) return 0; if (a > 0 && b < 0) return (a-b-1) / b; else if (a < 0 && b > 0) return (a-b+1) / b; else return a / b; } int main(){ ll N, M, L, R, X, Y, A, l, r; const ll K = 316; cin >> N >> M; vector ans(1e5+1); vector> cnt(K, vector(1e5+1)); for (int i=0; i> L >> R >> X >> Y; l = ceil(L-Y, X); r = floor(R-Y, X); if (X >= K){ for (int i=l; i<=r; i++) ans[X*i+Y]++; } else{ cnt[X][X*l+Y]++; if (X*r+Y+X<=1e5) cnt[X][X*r+Y+X]--; } } for (int i=0; i> A; cout << ans[A] << endl; } return 0; }