# luogu P5112 FZOUTSY

// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define LL long long
#define il inline
#define re register
#define db double

using namespace std;
const int N=3e6+10,M=1e5+10;
il int rd()
{
int x=0,w=1;char ch=0;
while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
return x*w;
}
int n,m,kk,szz;
int xzz[26]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,3,4,0,0,0,5,6},fa[N<<1],ch[N<<1][7],len[N<<1],id[N<<1],sa[N],tps,ls=1,tt=1;
char cc[N];
il void inst(char cc,int ii)
{
int np=++tt,p=ls;
len[np]=len[p]+1,id[np]=ii,ls=np;
while(p&&!ch[p][xzz[cc-'a']]) ch[p][xzz[cc-'a']]=np,p=fa[p];
if(!p) fa[np]=1;
else
{
int q=ch[p][xzz[cc-'a']];
if(len[q]==len[p]+1) fa[np]=q;
else
{
int nq=++tt;
fa[nq]=fa[q],len[nq]=len[p]+1,fa[q]=fa[np]=nq;
for(int i=0;i<7;++i) ch[nq][i]=ch[q][i];
while(p&&ch[p][xzz[cc-'a']]==q) ch[p][xzz[cc-'a']]=nq,p=fa[p];
}
}
}
int to[N<<1],nt[N<<1],hd[N<<1],tot;
int ff[N<<1],he[N];
il int findf(int x){return ff[x]==x?x:ff[x]=findf(ff[x]);}
void dd(int x)
{
if(id[x]) ++tps,sa[tps]=id[x],he[tps]=len[findf(ls)],ls=x;
for(int i=hd[x];i;i=nt[i]) dd(to[i]);
ff[x]=fa[x];
}
int be[N],p,mm[N],nm[N];
LL na,an[M];
il void dl(int i){--nm[be[i]],na-=nm[be[i]];}
struct qu
{
int l,r,i;
bool operator < (const qu &bb) const {return mm[l]!=mm[bb.l]?l<bb.l:/*((mm[l]&1)?r>bb.r:*/r<bb.r/*)*/;}
}qq[M];

int main()
{
n=rd(),m=rd(),kk=rd();
szz=n/sqrt(m);
scanf("%s",cc+1);
for(int i=1;i<=n;++i) inst(cc[n-i+1],n-i+1);
ls=0,dd(1);
for(int i=1;i<=n;++i) be[sa[i]]=p+=he[i]<kk,mm[i]=i/szz;
for(int i=1;i<=m;++i) qq[i].l=rd(),qq[i].r=rd(),qq[i].i=i;
sort(qq+1,qq+m+1);
for(int i=1,l=1,r=0;i<=m;++i)
{
while(r>qq[i].r) dl(r),--r;
while(l<qq[i].l) dl(l),++l;
}