//看看会不会爆int! #include #include #include #include #include #include using namespace std; #define ll long long #define pb push_back #define mkp make_pair #define fi first #define se second #define FOR(i, l, r) for(int i = l; i <= r; i++) #define ROF(i, r, l) for(int i = r; i >= l; i--) #define all(a) a.begin(), a.end() #define M 9973 int n, m, a, b; int h[100100]; char s[100100]; int pow(int a, int b){ int ans = 1; for(; b; b >>= 1, a = a * a % M) if(b & 1) ans = ans * a % M; return ans; } int main(){ while(~scanf("%d", &n)){ scanf("%s", s + 1); m = strlen(s + 1); h[0] = 1; for(int i = 1; i <= m; i++){ h[i] = h[i - 1] * (s[i] - 28) % M; if(h[i] < 0) h[i] += M; } while(n--){ scanf("%d%d", &a, &b); int ans = h[b] * pow(h[a - 1], M - 2) % M; printf("%d\n", ans); } } return 0; } /* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : |||// \ / _||||| -:- |||||- \ | | \\\ - /// | | | \_| ''\---/'' | | \ .-\__ `-` ___/-. / ___`. .' /--.--\ `. . __ ."" '< `.___\_<|>_/___.' >'"". | | : `- \`.;`\ _ /`;.`/ - ` : | | \ \ `-. \_ __\ /__ _/ .-` / / ======`-.____`-.___\_____/___.-`____.-'====== `=---=' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 佛祖保佑 永无BUG */