#include using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; /* dp[i][j]:=i日たったときに、向きがj(上、右上、左上、右、左)である確率 dp2[i][j]:=i日たったときに、向きがj(上、右上、左上、右、左)のときの期待値 */ template struct ModInt { ll value; ModInt(ll x = 0) { if (x >= 0) { value = x % MOD; } else { value = MOD - (-x) % MOD; } } ModInt operator-() const { return ModInt(-value); } ModInt operator+() const { return ModInt(*this); } ModInt &operator+=(const ModInt &other) { value += other.value; if (value >= MOD) { value -= MOD; } return *this; } ModInt &operator-=(const ModInt &other) { value += MOD - other.value; if (value >= MOD) { value -= MOD; } return *this; } ModInt &operator*=(const ModInt other) { value = value * other.value % MOD; return *this; } ModInt &operator/=(ModInt other) { (*this) *= other.inv(); return *this; } ModInt operator+(const ModInt &other) const { return ModInt(*this) += other; } ModInt operator-(const ModInt &other) const { return ModInt(*this) -= other; } ModInt operator*(const ModInt &other) const { return ModInt(*this) *= other; } ModInt operator/(const ModInt &other) const { return ModInt(*this) /= other; } ModInt pow(ll x) const { ModInt ret(1), mul(value); while (x) { if (x & 1) { ret *= mul; } mul *= mul; x >>= 1; } return ret; } ModInt inv() const { return pow(MOD - 2); } bool operator==(const ModInt &other) const { return value == other.value; } bool operator!=(const ModInt &other) const { return value != other.value; } friend ostream &operator<<(ostream &os, const ModInt &x) { return os << x.value; } friend istream &operator>>(istream &is, ModInt &x) { ll v; is >> v; x = ModInt(v); return is; } static constexpr ll get_mod() { return MOD; } }; using Mod998 = ModInt<998244353>; using Mod107 = ModInt<1000000007>; using mint = Mod998; int main() { int N; cin >> N; mint inv2 = mint(1) / 2, inv3 = mint(1) / 3; vector> dp(N + 1, vector(5)); dp[1][0] = dp[1][1] = dp[1][2] = dp[1][3] = dp[1][4] = mint(1) / 5; for (int i = 1; i < N; i++) { for (int j = 0; j < 5; j++) { mint c = j == 0 || j == 4 ? inv2 : inv3; if (j > 0) dp[i + 1][j - 1] += dp[i][j] * c; dp[i + 1][j] += dp[i][j] * c; if (j < 4) dp[i + 1][j + 1] += dp[i][j] * c; } } mint ans = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j < 4; j++) { ans += dp[i][j]; } } cout << ans << endl; }