/** * author: otera **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; //#define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef long double ld; const int inf=1e9+7; const ll INF=1LL<<60 ; const ll mod=1e9+7 ; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef complex Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair P; typedef pair LDP; typedef pair LP; #define fr first #define sc second #define all(c) c.begin(),c.end() #define pb push_back #define debug(x) cerr << #x << " = " << (x) << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { long long b = mod, u = 1, v = 0; while (b) { long long t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); } u %= mod; if (u < 0) u += mod; return u; } namespace NTT { const int MOD = 998244353; // to be set appropriately const long long PR = 3; // to be set appropriately void trans(vector &v, bool inv = false) { int n = (int)v.size(); for (int i = 0, j = 1; j < n-1; j++) { for (int k = n>>1; k > (i ^= k); k >>= 1); if (i > j) swap(v[i], v[j]); } for (int t = 2; t <= n; t <<= 1) { long long bw = modpow(PR, (MOD-1)/t, MOD); if (inv) bw = modinv(bw, MOD); for (int i = 0; i < n; i += t) { long long w = 1; for (int j = 0; j < t/2; ++j) { int j1 = i + j, j2 = i + j + t/2; long long c1 = v[j1], c2 = v[j2] * w % MOD; v[j1] = c1 + c2; v[j2] = c1 - c2 + MOD; while (v[j1] >= MOD) v[j1] -= MOD; while (v[j2] >= MOD) v[j2] -= MOD; w = w * bw % MOD; } } } if (inv) { long long inv_n = modinv(n, MOD); for (int i = 0; i < n; ++i) v[i] = v[i] * inv_n % MOD; } } // C is A*B vector mult(vector A, vector B) { int size_a = 1; while (size_a < A.size()) size_a <<= 1; int size_b = 1; while (size_b < B.size()) size_b <<= 1; int size_fft = max(size_a, size_b) << 1; vector cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0); for (int i = 0; i < A.size(); ++i) cA[i] = A[i]; for (int i = 0; i < B.size(); ++i) cB[i] = B[i]; trans(cA); trans(cB); for (int i = 0; i < size_fft; ++i) cC[i] = cA[i] * cB[i] % MOD; trans(cC, true); vector res((int)A.size() + (int)B.size() - 1); for (int i = 0; i < res.size(); ++i) res[i] = cC[i]; while(res.size() and res.back() == 0) res.pop_back(); return res; } }; ll fact[300300], factr[300300]; void solve() { string s; cin >> s; int n = (int)s.size(); vector cnt(26, 0); rep(i, n) { cnt[s[i] - 'a'] ++; } vector a(1, 1LL); sort(all(cnt)); rep(i, 5) { vector b(cnt[i] + 1, 1LL); ll cur = 1LL; rep(j, cnt[i] + 1) { if(j != 0) cur *= modinv(j, NTT::MOD); cur %= NTT::MOD; b[j] = cur; } a = NTT::mult(a, b); } } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(10); //int t; cin >> t; rep(i, t)solve(); solve(); return 0; }