#include #include #include #include #include #define LL long long using namespace std; const int maxn = 2000000 +10; const int mod = 9973; struct node { int L,R,sum; int Mid() {return L+(R-L)/2; } }tree[maxn*6]; char s[maxn]; void build(int c,int x,int y) { if (x == y) { tree[c].L = tree[c].R = x; tree[c].sum = ((int) s[x]) - 28; return; } tree[c].L = x ; tree[c].R = y; int mid = x+(y-x)/2; build(c*2 , x , mid); build(c*2+1, mid+1 , y); tree[c].sum = (tree[c*2].sum * tree[c*2+1].sum) % mod; } int query(int c, int x, int y) { if (tree[c].L == x && tree[c].R ==y) return tree[c].sum; int mid = tree[c].Mid(); if (y <= mid) return query(c*2 , x ,y); if (x > mid) return query(c*2+1 , x, y); return (query(c*2 , x, mid) * query(c*2+1 , mid + 1 , y)) % mod; } int main() { int N,ans; while(scanf("%d",&N)!=EOF) { scanf("%s",s+1); int n = strlen(s+1); build(1, 1 , n); while(N--) { int a,b; scanf("%d%d",&a,&b); if (a>=b) swap(a,b); if (b<=n) ans=query(1,a,b) % mod; printf("%d\n",ans); } } return 0; }