#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define forn(i,n) for(int i=0;i=R) return segtree[node]; else { int mid=L+(R-L)/2; int ans1=1; if(ql<=mid)ans1=query(node*2,L,mid,ql,qr); int ans2=1; if(qr>mid)ans2=query(node*2+1,mid+1,R,ql,qr); return (ans1*ans2)%mod; } } int main() { #ifdef LOCAL freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); #endif // LOCAL while(scanf("%d%s",&n,s)==2) { int len=strlen(s); build(1,0,len-1); while(n--) { int a,b; scanf("%d%d",&a,&b); printf("%d\n",query(1,0,len-1,a-1,b-1)); //printf("%d\n",query(a-1,b-1)); } } return 0; }