#include #include #include #include #include using namespace std; int n,t; char s[1000005]; int tree[4000005]; void build(int root,int l,int r){ if(l==r){ tree[root]=s[l]-28; return; } int m=(l+r)/2; build(root*2,l,m); build(root*2+1,m+1,r); tree[root]=tree[root*2]*tree[root*2+1]%9973; } int query(int root,int l,int r,int L,int R){ if(rR) return 1; if(L<=l && r<=R) return tree[root]; int tmp=1,m=(l+r)/2; tmp=tmp*query(root*2,l,m,L,R)%9973; tmp=tmp*query(root*2+1,m+1,r,L,R)%9973; return tmp; } int main(){ int pre=0; while(scanf("%d",&t)!=EOF){ scanf("%s",s); n=strlen(s); build(1,0,n-1); while(t--){ int a,b; scanf("%d%d",&a,&b); if(a>n || b>n || a<=0 || b<=0){ printf("%d\n",pre); continue; } pre=query(1,0,n-1,a-1,b-1); printf("%d\n",pre); } } }