#include #include #include #include #include #include using namespace std; const int maxn=1e5+5; const int maxb=350; int n,c,m,a[maxn],res,w[maxb][maxb],cnt[maxb][maxn],blo,tot,LP[maxb],RP[maxb],bid[maxn],tmp[maxn]; int main() { #ifdef local freopen("pro.in","r",stdin); #endif ios::sync_with_stdio(0); cin>>n>>c>>m; blo=sqrt(n); if(blo*blo>a[i]; cnt[bid[i]][a[i]]++; } for(int i=1;i<=tot;i++) for(int j=1;j0) { int l,r; cin>>l>>r; l=(l+res)%n+1; r=(r+res)%n+1; if(l>r) swap(l,r); // cout<<"["<bid[r]-1) { memset(tmp,0,sizeof(tmp)); res=0; for(int i=l;i<=r;i++) { if(tmp[a[i]]&&(tmp[a[i]]&1)==0) res--; tmp[a[i]]++; if((tmp[a[i]]&1)==0) res++; } cout<