### 代码

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<iostream>
#define llong long long
using namespace std;

{
int x=0; bool f=1; char c=getchar();
for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
if(f) return x;
return -x;
}

const int N = 1e5+1;
const int P = 998244353;
const llong INV2 = 499122177;
llong fact[N+3],finv[N+3];
int n;

llong quickpow(llong x,llong y)
{
llong cur = x,ret = 1ll;
for(int i=0; y; i++)
{
if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
cur = cur*cur%P;
}
return ret;
}
llong mulinv(llong x) {return quickpow(x,P-2);}
llong comb(llong x,llong y) {return x<0||y<0||x<y ? 0ll : fact[x]*finv[y]%P*finv[x-y]%P;}

llong a[N+3];
llong aa[N+3];
llong b[N+3];

int main()
{
fact[0] = 1ll; for(int i=1; i<=N; i++) fact[i] = fact[i-1]*i%P;
finv[N] = quickpow(fact[N],P-2); for(int i=N-1; i>=0; i--) finv[i] = finv[i+1]*(i+1)%P;
scanf("%d",&n);
for(int i=0; i<=n+1; i++)
{
a[i] = quickpow(2ll,n+1)*comb(n+1,i);
if((n+1-i)&1) {a[i] = P-a[i];}
}
a[0]--;
for(int i=n; i>=0; i--)
{
aa[i] = a[i+1]*INV2%P;
a[i] = (a[i]+3ll*aa[i])%P;
}
b[0] = 1ll; b[1] = n+1;
for(int i=2; i<=n; i++)
{
b[i] = (quickpow(i,n+1)-1)*mulinv(i-1)%P;
}
llong ans = 0ll;
for(int i=0; i<=n; i++) {ans = (ans+aa[i]*b[i])%P;}
printf("%lld\n",ans);
return 0;
}