#include using namespace std; const long long MOD = 998244353; const long long ONE_SIXTH = 166374059; int main(){ int N, K; cin >> N >> K; vector P(6, ONE_SIXTH); auto mul = [&](vector A, vector B){ vector C(6, 0); for (int i = 0; i < 6; i++){ for (int j = 0; j < 6; j++){ C[i * j % 6] += A[i] * B[j]; C[i * j % 6] %= MOD; } } return C; }; vector ans(6, 0); ans[1] = 1; while (N > 0){ if (N % 2 == 1){ ans = mul(ans, P); } P = mul(P, P); N /= 2; } cout << ans[K] << endl; }