#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; const int N = 1005, m = 1000000007; char s[N]; int cnt[26]; long long rev[N]; void solve() { scanf("%s", s); int n=strlen(s); memset(cnt, 0, sizeof(cnt)); for (int i=0; i 1) { res = 0; } printf("%I64d\n", res); } long long extend_gcd(long long a, long long b, long long &x, long long &y) { if (a==0&&b==0) return -1ll; if (b==0) { x=1ll; y=0ll; return a; } long long d=extend_gcd(b, a%b, y, x); y-=a/b*x; return d; } long long mod_reverse(long long a, long long n) { long long x, y, d=extend_gcd(a, n, x, y); if (d==1) return (x%n+n)%n; else return -1ll; } void prepare() { for (int i=0; i