#include #include #include #include using namespace std; #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 typedef long long ll; const int maxn = 100006; ll sum[maxn<<4]; const int mod = 9973; char s[maxn]; void PushUp(ll rt) { sum[rt] = sum[rt<<1]*sum[rt<<1|1]%mod; } void build(ll l,ll r,ll rt) { if(l == r){ sum[rt] = (s[l]-28)%mod; return ; } ll m = (l+r)>>1; build(lson); build(rson); PushUp(rt); } ll query(ll L,ll R,ll l,ll r,ll rt) { if(L <= l&&r <= R) { return sum[rt]; } ll m = (l+r)>>1; ll ret = 1; if(L <= m) ret*=query(L,R,lson); if(m < R) ret*= query(L,R,rson); return ret%mod; } int main() { ll q; int l, r; while(scanf("%I64d",&q)==1){ scanf("%s",s+1); int n = strlen(s+1); build(1,n,1); while(q--){ scanf("%d%d",&l,&r); printf("%I64d\n",query(l,r,1,n,1)); } } return 0; }