#include #include #include #include #include #include #include #include #include using namespace std; #define N 221000 const int MOD = 9973; #define met(a, b) memset(a, b, sizeof(a)) typedef long long LL; char str[N]; int sum[N]; int Quick_Pow (int m, int n) { int b = 1; while (n) { if (n&1) b = (b*m%MOD) % MOD; m = (m*m%MOD)%MOD; n /= 2; } return b; } int main () { int n, ans, tt; while (scanf ("%d", &n) != EOF) { scanf ("%s", str+1); sum[0] = 1; for (int i=1; str[i]; i++) sum[i] = (sum[i-1]*(str[i]-28)%MOD)%MOD; while (n--) { int sa, en; scanf ("%d %d", &sa, &en); tt = Quick_Pow (sum[sa-1], MOD-2); ans = (sum[en] * tt % MOD) % MOD; printf ("%d\n", ans); } } return 0; }