#if 1 // clang-format off #include #include using namespace atcoder; using mint93 = modint998244353; using mint17 = modint1000000007; using mint = modint; using vm93 = std::vector; using vvm93 = std::vector; using vm17 = std::vector; using vvm17 = std::vector; using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using lf = long double; using pll = pair; #define vec vector template using v = vector; template using vv = v>; template using vvv = v>; using vl = v; using vvl = vv; using vvvl = vvv; using vpl = v; using vs = v; using vb = v; using vvb = v; using vvvb = v; template using PQ = priority_queue, greater>; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define rep(i, N) for (ll i = 0; i < (ll)(N); i++) #define rep1(i, N) for (ll i = 1; i <= (ll)(N); i++) #define rrep(i, N) for (ll i = N - 1; i >= 0; i--) #define rrep1(i, N) for (ll i = N; i > 0; i--) #define fore(i, a) for (auto &i : a) #define fs first #define sc second #define eb emplace_back #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define UNIQUE(x) (x).erase(unique((x).begin(), (x).end()), (x).end()); #define YES(x) cout << ((x) ? "YES\n" : "NO\n"); #define Yes(x) cout << ((x) ? "Yes\n" : "No\n"); #define yes(x) cout << ((x) ? "yes\n" : "no\n"); template void chmin(T &t, const U &u) { if (t > u) t = u; } template void chmax(T &t, const U &u) { if (t < u) t = u; } template T min(const v &lis) { return *min_element(all(lis)); } template T max(v &lis) { return *max_element(all(lis)); } const int inf = (1 << 30); const ll infl = (1LL << 60); const ll mod93 = 998244353; const ll mod17 = 1000000007; int popcnt(uint x) { return __builtin_popcount(x); } int popcnt(ull x) { return __builtin_popcountll(x); } // 桁数 int bsr(uint x) { return 31 - __builtin_clz(x); } int bsr(ull x) { return 63 - __builtin_clzll(x); } // 2で割れる回数 int bsf(uint x) { return __builtin_ctz(x); } int bsf(ull x) { return __builtin_ctzll(x); } template istream &operator>>(istream &is, pair &x) { return is >> x.first >> x.second; } template ostream &operator<<(ostream &os, const pair &x) { return os << x.first << " " << x.second; } template istream &operator>>(istream &is, vector &x) { for (auto &y : x) is >> y; return is; } template ostream &operator<<(ostream &os, const vector &x) { for (size_t i = 0, size = x.size(); i < size; i++) os << x[i] << (i == size - 1 ? "" : " "); return os; } ll rand_int(ll l, ll r) { // [l, r] static random_device rd; static mt19937 gen(rd()); return uniform_int_distribution(l, r)(gen); } template struct binomial { long long n; std::vector> fact, ifact; binomial(long long n) : n(n), fact(n + 1), ifact(n + 1) { fact[0] = 1; for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i > 0; i--) ifact[i - 1] = ifact[i] * i; } atcoder::static_modint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; // #include // using cpp_int = boost::multiprecision::cpp_int; // clang-format on #endif // #define _GLIBCXX_DEBUG struct S { array, 3> A; }; void add(vm93 &a, vm93 &b) { if (a.size() < b.size()) swap(a, b); rep(i, b.size()) a[i] += b[i]; } S e() { S ret; rep(i, 3) { rep(j, 3) { ret.A[i][j] = vm93(1); if (i == j) ret.A[i][j][0] = 1; } } return ret; } S op(S a, S b) { S ret; rep(now, 3) { rep(mid, 3) { rep(to, 3) { vm93 tmp = convolution(a.A[now][mid], b.A[mid][to]); add(ret.A[now][to], tmp); while (ret.A[now][to].size() > 0 && ret.A[now][to].back() == 0) ret.A[now][to].pop_back(); } } } return ret; } S one() { S ret; mint93 two = mint93(2).inv(); mint93 th = mint93(3).inv(); ret.A = array, 3>{ array{vm93{0, th}, {0, 2*th}, {}}, array{vm93{0, th}, {0, th}, {th, 0}}, array{ vm93{}, {0, two}, {two, 0}} }; return ret; } void print(S a) { rep(i, 3) { rep(j, 3) { cout << "{"; ll sz = a.A[i][j].size(); rep(k, sz) { if (k > 0) cout << " "; cout << a.A[i][j][k].val(); } cout << "}"; } cout << "\n"; } } S doubling(ll N) { S ret = e(), cur = one(); while (N) { if (N & 1) ret = op(ret, cur); cur = op(cur, cur); N >>= 1; } return ret; } struct Solver { void solve() { ll N, H; cin >> N >> H; S res = doubling(N - 1); // print(res); mint93 ans_top = 0, ans_bot = 0; rep(i, 3) { mint93 tmp_top = 0, tmp_bot = 0; rep(j, 3) { ll sz = res.A[i][j].size(); rep(k, sz) { tmp_bot += res.A[i][j][k]; } FOR(k, H, sz) { tmp_top += res.A[i][j][k]; } if (i != 2 && H - 1 < sz) { tmp_top += res.A[i][j][H - 1]; } } if (i != 0) tmp_top *= 2, tmp_bot *= 2; ans_top += tmp_top; ans_bot += tmp_bot; // cout << i << " " << tmp_top.val() << " " << tmp_bot.val() << "\n"; } mint93 ans = ans_top / ans_bot; // cout << ans_top.val() << " " << ans_bot.val() << "\n"; cout << ans.val() << "\n"; } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); ll t = 1; // cin >> t; while (t--) { Solver solver; solver.solve(); } }