#include #include #include #include #include #include #include #include #include #include #define mod 9973 using namespace std; char str[100005]; int tt[100005]; int n; int a,b; int temp; int ans; int main() { //freopen("input.txt","r",stdin); // tt[0]=1; while(scanf("%d",&n)==1) { scanf("%s",str); int len=strlen(str); for(int i=1; i<=len; i++) { tt[i]=(str[i-1]+mod-28)*tt[i-1]%mod; } while(n--) { scanf("%d%d",&a,&b); if(a<1||a>len||b<1||b>len||a>b) { goto look; } for(int j=0; j