#include using namespace std; struct Mo { Mo(int _n, int _q):n(_n),q(_q){querys.reserve(_n);} void add(int l, int r){querys.emplace_back(l,r);} template void build(const ExL&exl, const ExR&exr, const ShL&shl, const ShR&shr, const O&out) { const int b=n/max(1,min(n,(int)sqrt(q*2.0/3.0))); vectoridx(q); for(int i=0;irj:rili)exl(--l); while(rri)shr(--r); out(i); } } private: int n,q; vector>querys; }; int N,Q,A[1<<16],K[1<<16],cnt[1<<17]; int ans[1<<16]; vectorfac[1<<16]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>Q; for(int i=0;i>A[i]; for(int a=1;a*a<=A[i];a++)if(A[i]%a==0) { fac[i].push_back(a); if(a*a!=A[i])fac[i].push_back(A[i]/a); } sort(fac[i].begin(),fac[i].end()); } auto ex=[&](int i){for(int a:fac[i])cnt[a]++;}; auto sh=[&](int i){for(int a:fac[i])cnt[a]--;}; auto out=[&](int i){ans[i]=cnt[K[i]];}; Mo mo(N,Q); for(int i=0;i>l>>r>>K[i]; mo.add(l-1,r); } mo.build(ex,ex,sh,sh,out); for(int i=0;i