#include using namespace std; using ll = long long; using pll = pair; using vl = vector ; //1D using vvl = vector ;//2D using vvvl = vector ;//3D using vvvvl = vector;//4D using vvvvvl = vector;//5D using vvvvvvl = vector;//6D using vvvvvvvl = vector;//7D using vp = vector ; //1D using vvp = vector ;//2D using vvvp = vector ;//3D using vvvvp = vector;//4D using vvvvvp = vector;//5D using vvvvvvp = vector;//6D using vvvvvvvp = vector;//7D using vi = vector ; //1D using vvi = vector ;//2D using vvvi = vector ;//3D using vvvvi = vector;//4D using vvvvvi = vector;//5D using vvvvvvi = vector;//6D using vvvvvvvi = vector;//7D using vb = vector ; //1D using vvb = vector ;//2D using vvvb = vector ;//3D using vvvvb = vector;//4D using vvvvvb = vector;//5D using vvvvvvb = vector;//6D using vvvvvvvb = vector;//7D using vs = vector ; //1D using vvs = vector ;//2D using vvvs = vector ;//3D using vvvvs = vector;//4D using vvvvvs = vector;//5D using vvvvvvs = vector;//6D using vvvvvvvs = vector;//7D [[maybe_unused]] const ll INF = 2e18 ; [[maybe_unused]] const ll MOD = 998244353; #define rep(i,a,b) for(ll i=(ll)a; i<(ll)b; i++) #define rrep(i,a,b) for(ll i=(ll)b-1; i>=(ll)a; i--) #define all(vec1) (vec1).begin(), (vec1).end() #define yn(b,ex) if(1){if(b)cout << "Yes" << endl;else cout << "No" << endl ;if(ex)return 0;} #define debug(var) cerr << #var << " : " << var << endl; //fastio struct FastIO { FastIO() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } fastio; //あまり(負の数対応) template T ovr(T a,T b){ T ret=a%b; if(ret<0)ret+=b; return ret; } template bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } /////////main///////// // https://tjkendev.github.io/procon-library/cpp/series/kitamasa.html #include using namespace atcoder; using mint = modint998244353; struct Mat { mint a00, a01, a10, a11; Mat operator+(const Mat& b) const { return Mat{a00 + b.a00, a01 + b.a01, a10 + b.a10, a11 + b.a11}; } Mat& operator+=(const Mat& b) { a00 += b.a00; a01 += b.a01; a10 += b.a10; a11 += b.a11; return *this; } Mat operator*(const Mat& b) const { return Mat{ a00 * b.a00 + a01 * b.a10, a00 * b.a01 + a01 * b.a11, a10 * b.a00 + a11 * b.a10, a10 * b.a01 + a11 * b.a11 }; } // スカラー倍 Mat operator*(const mint& k) const { return Mat{a00 * k, a01 * k, a10 * k, a11 * k}; } Mat& operator*=(const mint& k) { a00 *= k; a01 *= k; a10 *= k; a11 *= k; return *this; } }; // 左からスカラー倍もできるように Mat operator*(const mint& k, const Mat& a) { return a * k; } struct Vec { mint a0, a1; Vec operator+(const Vec& b) const { return Vec{a0 + b.a0, a1 + b.a1}; } Vec& operator+=(const Vec& b) { a0 += b.a0; a1 += b.a1; return *this; } // スカラー倍 Vec operator*(const mint& k) const { return Vec{a0 * k, a1 * k}; } Vec& operator*=(const mint& k) { a0 *= k; a1 *= k; return *this; } }; // 左からも Vec operator*(const mint& k, const Vec& v) { return v * k; } // 行列×ベクトル Vec operator*(const Mat& a, const Vec& b) { return Vec{ a.a00 * b.a0 + a.a01 * b.a1, a.a10 * b.a0 + a.a11 * b.a1 }; } ll F; // (0-indexed) // a[i] = a_i, c[i] = c_i // a_{i+k} = c_i*a_i + c_{i+1}*a_{i+1} + ... + c_{i+k-1}*a_{i+k-1} vector c; vector a; // C(N, *) -> C(N+1, *) void nxt(ll k, vector&c0, vector&c1) { c1[0] = (c0[k-1] * c[0]); for(ll i=0; i C(2N, *) void dbl(ll k, vector&c0, vector&c1) { vector> cs(F, vector(F)); for(ll i=0; i c0(F), c1(F); if(m == 0) { return a[0]; } for(ll i=0; i> --p) & 1) == 0); while(p-- > 0) { dbl(k, c0, c0); if((m >> p) & 1) { nxt(k, c0, c1); for(ll j=0; j> N >> K; if (K < 4 * N) {cout << 0 << endl; return 0;} F = 4 * N - 1; c.assign(F, {0,3,0,1}); c.back() = {4,3,1,1}; rep(i,0,F) if(i % 4 == 3) c[i] = {0,4,0,0}; a.assign(F, {0,0}); a.back() = {1,0}; auto ans = solve(K-1, F); ans.a1 /= mint(5).pow(K); cout << ans.a1.val() << endl; }