1 #include<iostream>
2 #include<cstring>
3 #include<cstdio>
4 #define ll __int64
5 #define mod 9973
6 using namespace std;
7 int n;
8 char a[100005];
9 ll gg[100005];
10 ll sum=1;
11 int l,r;
12 ll quickmod(ll a,ll b)
13 {
14 ll sum=1;
15 while(b)
16 {
17 if(b&1)
18 sum=(sum*a)%mod;
19 b>>=1;
20 a=(a*a)%mod;
21 }
22 return sum;
23 }
24 int main()
25 {
26 while(scanf("%d",&n)!=EOF)
27 {
28 memset(a,0,sizeof(a));
29 scanf("%s",a);
30 int len=strlen(a);
31 gg[0]=1;
32 sum=1;
33 for(int i=0;i<len;i++)
34 {
35 sum=(sum*(a[i]-28))%mod;
36 gg[i+1]=sum%mod;
37 }
38 for(int i=1;i<=n;i++)
39 {
40 scanf("%d %d",&l,&r);
41 ll ggg=quickmod(gg[l-1],mod-2);
42 printf("%I64d\n",(gg[r]*ggg)%mod);
43 }
44 }
45 return 0;
46 }