#include using namespace std; const long long MOD = 998244353; const long long ONE_THIRD = 332748118; array operator +(array A, array B){ array C = {}; for (int i = 0; i < 3; i++){ C[i] = (A[i] + B[i]) % MOD; } return C; } array operator *(array A, long long k){ for (int i = 0; i < 3; i++){ A[i] *= k; A[i] %= MOD; } return A; } array operator *(array A, array B){ array C = {}; for (int i = 0; i < 3; i++){ for (int j = 0; j < 3; j++){ int k = (i + j) % 3; C[k] += A[i] * B[j]; C[k] %= MOD; } } return C; } array pow(array A, int N){ array ans = {1, 0, 0}; while (N > 0){ if (N % 2 == 1){ ans = ans * A; } A = A * A; N /= 2; } return ans; } array shift(array A, int N){ array B = {}; for (int i = 0; i < 3; i++){ B[(i + N) % 3] = A[i]; } return B; } int main(){ int N, M; cin >> N >> M; vector> binom(M + 1, vector(M + 1, 0)); for (int i = 0; i <= M; i++){ binom[i][0] = 1; for (int j = 1; j < i; j++){ binom[i][j] = (binom[i - 1][j - 1] + binom[i - 1][j]) % MOD; } binom[i][i] = 1; } array ans = {}; for (int i = 0; i <= M; i++){ for (int j = 0; i + j <= M; j++){ int k = M - i - j; long long c = binom[M][i] * binom[M - i][j] % MOD; array x = {i, j, k}; ans = ans + shift(pow(x, N), j * 2 + k) * c; } } long long ans2 = (ans[0] - ans[1] + MOD) % MOD; for (int i = 0; i < M; i++){ ans2 *= ONE_THIRD; ans2 %= MOD; } cout << ans2 << endl; }