#include using namespace std; constexpr int mod = 998244353; long long fac[200005], finv[200005], inv[200005]; void COMinit() { fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1; for (int i = 2; i < 200005; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } long long choose(int n,int k) { if(n < 0 || k < 0) return 0; if(n == 0) return 1; return COM(n+k-1,k-1); } long long modpow(long long a,long long b) { long long ans = 1; while(b) { if(b & 1) { (ans *= a) %= mod; } (a *= a) %= mod; b /= 2; } return ans; } void mpl(int &x,int y) { x += y; if(x >= mod) x -= mod; } int dp[10001000][4]; int dp2[10001000][4]; int main() { int N; cin >> N; int ans = 0; dp[0][0] = 1; dp2[0][0] = 1; for(int i = 0; i < N; i++) { for(int j = 0; j <= 3; j++) { mpl(dp[i+1][j],1ll*dp[i][j]*i%mod); for(int k = j; k <= j+1; k++) { if(k == 4) continue; mpl(dp[i+1][k],dp[i][j]); } mpl(dp2[i+1][j],1ll*dp2[i][j]*i%mod); if(j != 3) { mpl(dp2[i+1][j+1],dp2[i][j]); } } } mpl(ans,6ll*dp[N][3]%mod); mpl(ans,6ll*dp[N][2]%mod); mpl(ans,dp[N][1]); cout << ans << endl; }