using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var mod = 998_244_353; var r2 = 499122177; var r3 = 332748118; var r5 = 598946612; var dp = Enumerable.Repeat((long)r5, 5).ToArray(); var ans = r5 * 3L % mod; for (var i = 1; i < n; ++i) { var ndp = new long[5]; ndp[0] = (dp[0] * r2 % mod + dp[1] * r3 % mod) % mod; ndp[1] = (dp[0] * r2 % mod + dp[1] * r3 % mod + dp[2] * r3 % mod) % mod; ndp[2] = (dp[1] + dp[2] + dp[3]) * r3 % mod; ndp[3] = (dp[2] * r3 % mod + dp[3] * r3 % mod + dp[4] * r2 % mod) % mod; ndp[4] = (dp[3] * r3 % mod + dp[4] * r2 % mod) % mod; ans = (ans + ndp[1] + ndp[2] + ndp[3]) % mod; dp = ndp; } WriteLine(ans); } }