#include #define LL long long #define MOD 1000000007 int ans,N,a[300009],i1[300009],n1[300009],c1[300009],s1[300009], b[300009],SZ1,SZ2,le,i2[300009],n2[300009],c2[300009],s2[300009]; struct n_t{ int h1,p1,h2,p2; } t[300009]; bool cmp(n_t x,n_t y) { if(x.h1!=y.h1) return x.h1 tp; tp.push_back(0); tp.push_back(1ll*SZ1*SZ2/le); for(int i=l+1;i<=r;i++) { tp.push_back(qr((t[i].p1-t[l].p1+SZ1)%SZ1,(t[i].p2-t[l].p2+SZ2)%SZ2)); } std::sort(tp.begin(),tp.end()); for(int i=0;i+1