let [n; m] = read_line () |> String.split_on_char ' ' |> List.map int_of_string;; let s = m * m * m;; let md = 998244353;; let prod a b = begin let c = Array.make (s*s) 0 in for i = 0 to s - 1 do for k = 0 to s - 1 do for j = 0 to s - 1 do c.(i*s+j) <- (c.(i*s+j) + a.(i*s+k) * b.(k*s+j)) mod md done done done; c end;; let power a k = begin let res = ref (Array.make (s*s) 0) in for i = 0 to s - 1 do !res.(i*s+i) <- 1 done; let a = ref a in let k = ref k in while !k > 0 do if !k mod 2 = 1 then res := prod !res !a; a := prod !a !a; k := !k / 2; done; !res end;; let a = Array.make (s*s) 0;; let f i j k = let i = i mod m in let j = j mod m in let k = k mod m in i*m*m + j*m + k;; let inc a i j = a.(i*s+j) <- a.(i*s+j) + 1;; for i = 0 to m - 1 do for j = 0 to m - 1 do for k = 0 to m - 1 do inc a (f (i+1) j k) (f i j k); inc a (f i (j+i) k) (f i j k); inc a (f i j (k+j)) (f i j k); done done done;; let a = power a n;; let ans = ref 0;; for i = 0 to m - 1 do for j = 0 to m - 1 do ans := (!ans + a.(f i j 0)) mod md; done done;; print_int !ans;; print_newline ();;