#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n,m,c,siz,ans,num;
int f[320][320],g[320][100010],v[100010],s[100010],p[640];
int main()
{
scanf("%d%d%d",&n,&c,&m);
int i,j,a,b;
siz=int(sqrt(1.0*n));
for(i=0;i<n;i++) scanf("%d",&v[i]),g[i/siz][v[i]]++;
for(i=0;i<=n/siz;i++)
{
if(i) for(j=1;j<=c;j++) g[i][j]+=g[i-1][j];
memset(s,0,sizeof(s));
for(j=i*siz;j<n;j++)
{
s[v[j]]++;
if(s[v[j]]==2) f[i][j/siz]++;
if(s[v[j]]==3) f[i][j/siz]--,s[v[j]]=1;
if(j&&j%siz==0) f[i][j/siz]+=f[i][j/siz-1];
}
}
for(i=1;i<=m;i++)
{
scanf("%d%d",&a,&b);
a=(a+ans)%n,b=(b+ans)%n;
num=0;
if(a>b) swap(a,b);
if(a/siz==b/siz)
{
ans=0;
for(j=a;j<=b;j++) p[num++]=v[j];
sort(p,p+num);
int pre=0;
for(j=0;j<num;j++)
{
if(j&&p[j]!=p[j-1])
{
ans+=(pre%2==0)?1:0;
pre=0;
}
pre++;
}
ans+=(pre%2==0)?1:0;
}
else
{
ans=f[a/siz+1][b/siz-1];
for(j=a;j<(a/siz+1)*siz;j++) p[num++]=v[j];
for(j=b/siz*siz;j<=b;j++) p[num++]=v[j];
sort(p,p+num);
int pre=0;
for(j=0;j<num;j++)
{
if(j&&p[j]!=p[j-1])
{
if(g[b/siz-1][p[j-1]]>g[a/siz][p[j-1]]&&((g[b/siz-1][p[j-1]]-g[a/siz][p[j-1]])%2==0)) ans--;
if((pre+g[b/siz-1][p[j-1]]-g[a/siz][p[j-1]])%2==0) ans++;
pre=0;
}
pre++;
}
if(g[b/siz-1][p[num-1]]>g[a/siz][p[num-1]]&&((g[b/siz-1][p[num-1]]-g[a/siz][p[num-1]])%2==0)) ans--;
if((pre+g[b/siz-1][p[num-1]]-g[a/siz][p[num-1]])%2==0) ans++;
}
printf("%d\n",ans);
}
return 0;
}