#include #include #include #include using namespace std; typedef long long ll; const int mod = 9973; const int maxn = 1e5+10; char str[maxn]; ll h[maxn]; int inv[maxn]={0,1}; int main(){ int n,a,b; for(int i = 2;i <= mod+10;i++){ inv[i]=inv[mod%i]*(mod-mod/i)%mod; } while(scanf("%d",&n) != EOF){ scanf("%s",str); int len = strlen(str); h[0] = 1; h[1] = str[0]-28; for(int i = 1;i < len;i++){ h[i+1] = h[i]*(str[i]-28)%mod; } for(int i = 0;i < n;i++){ scanf("%d%d",&a,&b); ll ans = h[b]*inv[h[a-1]]%mod; printf("%I64d\n",ans); } } return 0; }