// clang-format off #include #include #include #define mp make_pair #define fst first #define snd second #define forn(i,n) for (int i = 0; i < int(n); i++) #define forn1(i,n) for (int i = 1; i <= int(n); i++) #define popcnt __builtin_popcountll #define ffs __builtin_ffsll #define ctz __builtin_ctzll #define clz __builtin_clz #define clzll __builtin_clzll #define all(a) (a).begin(), (a).end() using namespace std; using namespace __gnu_pbds; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using pii = pair; using pli = pair; using pil = pair; using pll = pair; template using vec = vector; using vi = vec; using vl = vec; template using que = queue; template using deq = deque; template using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>; template using ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>; template T id(T b) {return b;}; template void chmax(T &x, T y) {if (x < y) x = y;} template void chmin(T &x, T y) {if (x > y) x = y;} template bool contains(S &s, K k) { return s.find(k) != s.end(); } template bool getf(T flag, size_t i) { return (flag>>i) & 1; } template T setf(T flag, size_t i) { return flag | (T(1)< T unsetf(T flag, size_t i) { return flag & ~(T(1)<> n >> s; const ll MOD = 998244353; auto idx = [](char c1, char c2) { return (c1 - 'a') * 27 + c2 - 'a'; }; vl dp(27 * 27); dp[27 * 27 - 1] = 1; forn(i, n) { vl temp(27 * 27); for (char c2 = 'a'; c2 <= 'z'; c2++) { if (s[i] == '?' or s[i] == c2) { for (char c0 = 'a'; c0 <= '{'; c0++) { for (char c1 = 'a'; c1 <= '{'; c1++) { if (c0 != c2 and c1 != c2) { temp[idx(c1, c2)] = (temp[idx(c1, c2)] + dp[idx(c0, c1)]) % MOD; } } } } } dp = temp; } ll ans = 0; for (char c0 = 'a'; c0 <= '{'; c0++) { for (char c1 = 'a'; c1 <= '{'; c1++) { ans = (ans + dp[idx(c0, c1)]) % MOD; } } cout << ans << endl; return 0; }