#include #include #include using namespace std; const int M= 9973; char s[100005]; long long num[100005]; long long quickpow(long long a, long long b) { if(b < 0) return 0; long long ret = 1; a %= M; for (; b; b >>= 1, a = (a * a) % M) if (b & 1) ret = (ret * a) % M; return ret; } long long inv(long long a) { return quickpow(a,M-2);//注意这里是-2不是-1 } int main () { int N; num[0]=1; while(~scanf("%d",&N)) { scanf("%s",s+1); for (int i=1; s[i]!=0;i++ ) { num[i]=(num[i-1]*(s[i]-28))%M; } for (int i=0;i