#include #include #include #include #include using namespace std; const int N = 100500; const int M = 270000; const int T = 131072; const int Mod = 9973; char dr[N]; int xu[N]; int tree[M]; int n,m; void Change(int x,int y) { x+=T; tree[x]=y; x>>=1; while(x) { tree[x]=tree[x*2]*tree[x*2+1]; tree[x]%=Mod; x>>=1; } } int Find(int x,int y) { x+=T-1; y+=T+1; int res=1; while(x^y^1) { if(x%2==0) { res*=tree[x^1]; res%=Mod; } if(y%2==1) { res*=tree[y^1]; res%=Mod; } x>>=1; y>>=1; } return res; } void f() { int i; scanf("%s",dr+1); n=strlen(dr+1); for(i=1;i<=n;i++) xu[i]=dr[i]-28; for(i=1;i<=n;i++) Change(i,xu[i]); while(m--) { int a,b; scanf("%d%d",&a,&b); int c=Find(a,b); printf("%d\n",c); } } int main() { while(scanf("%d",&m)!=EOF) f(); return 0; }