#include #include namespace neguse {} using namespace std; using namespace atcoder; using namespace neguse; typedef long long ll; typedef long double ld; typedef pair pii; typedef pair pll; typedef vector vi; typedef vector vll; typedef vector vld; typedef vector vvi; typedef vector vvll; typedef vector vs; typedef vector vpii; typedef vector vpll; #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);iint(b);--i) #define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep)(__VA_ARGS__) #define _each1(i,v) for(auto& i:v) #define _each2(i,j,v) for(auto& [i,j]:v) #define each(...) _overload3(__VA_ARGS__,_each2,_each1,)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define SORT(x) sort(all(x)) #define RSORT(x) sort(rall(x)) #define REVERSE(x) reverse(all(x)) #define dump(x) cerr << #x << " = " << (x) << '\n' #define print(x) cout << (x) << '\n' #define yes(f) cout << ((f) ? "Yes" : "No") << '\n' #define ge(v, x) (int)(lower_bound(all(v), x) - v.begin()) #define gt(v, x) (int)(upper_bound(all(v), x) - v.begin()) #define le(v, x) (int)(upper_bound(all(v), x) - v.begin())-1 #define lt(v, x) (int)(lower_bound(all(v), x) - v.begin())-1 templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b istream& operator>>(istream& is, vector& vec) { for (T& x : vec) is >> x; return is; } template ostream& operator<<(ostream& os, const vector& vec) { for (const T& x : vec) os << x << ' '; return os; } int main() { ll N; cin >> N; int K; cin >> K; using mint = modint998244353; vector fact(K + 1), ifact(K + 1); fact[0] = 1; rep(i, K) fact[i + 1] = fact[i] * (i + 1); rep(i, K + 1) ifact[i] = 1 / fact[i]; auto comb = [&](int n, int k) { if (n < k || n < 0 || k < 0) return mint(0); return fact[n] * ifact[k] * ifact[n - k]; }; using mat = vector>; mat M = mat(K + 2, vector(K + 2)); rep(r, K + 1) rep(t, r + 1) M[r][K - t] = comb(r, t); M[K + 1][K] = M[K + 1][K + 1] = 1; auto mul = [&](const mat& A, const mat& B) { mat C(K + 2, vector(K + 2)); rep(i, K + 2) rep(j, K + 2) rep(k, K + 2) C[i][j] += A[i][k] * B[k][j]; return C; }; auto pow = [&](mat A, ll n) { mat B(K + 2, vector(K + 2)); rep(i, K + 2) B[i][i] = 1; while (n) { if (n & 1) B = mul(B, A); A = mul(A, A); n >>= 1; } return B; }; M = pow(M, N - 1); mint ans = 0; rep(i, K + 2) ans += M[K + 1][i]; cout << ans.val() << endl; }