#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; const int maxn = 100005, mod = 9973; char str[maxn]; LL ans[maxn]; inline LL read() { int c=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { c=c*10+ch-'0'; ch=getchar(); } return c*f; } LL Quick_Mod(LL a,LL b) { LL ans=a,ret=1; while(b) { if(b&1) ret = ret*ans%mod; b>>=1; ans=ans*ans%mod; } return ret; } void solve ( ) { int n, a, b; while (~scanf ( "%d", &n )) { scanf ("%s",str+1); int len = strlen (str+1); ans[0] = 1; for ( int i = 1; i <= len; i ++ ) ans[i] = ans[i-1]*(str[i]-28)%mod; while(n--) { scanf("%d%d", &a, &b); LL k=(ans[a-1]+mod)%mod; LL res=Quick_Mod(k, mod-2 )*ans[b]%mod; printf("%lld\n",(res+mod)%mod); } } } int main ( ) { //freopen("1.txt","r",stdin); solve ( ); return 0; }