#include using namespace std; using ll=long long; using P=pair; struct Tree{ int n; vector vec; Tree(int _n){ n=1; while(n<_n){ n*=2; } vec.assign(n*2+10,0); } void update(int k,ll x){ k+=n; vec[k]=x; k/=2; while(k){ vec[k]=vec[k*2]+vec[k*2+1]; k/=2; } } ll sum(int l,int r){ ll ans=0; l+=n; r+=n; while(lP(o.l,o.r); } return n>o.n; } return f>o.f; } return x>o.x; } }; int main(){ int n,m; cin>>n>>m; vector que; for(int i=0;i>t; que.push_back(Query(i,t)); } for(int i=0;i>a>>b>>c>>d; b--;c--; que.push_back(Query(i,b,c,d)); } sort(que.begin(),que.end()); Tree tr(n); Tree cn(n); vector ans(m); for(int i=0;i