Problem:
Score : 800 points

Problem Statement

Given is a positive even number N.

Find the number of strings s of length N consisting of A, B, and C that satisfy the following condition:

s can be converted to the empty string by repeating the following operation:

Choose two consecutive characters in s and erase them. However, choosing AB or BA is not allowed.

For example, ABBC satisfies the condition for N=4, because we can convert it as follows: ABBC → (erase BB) → AC → (erase AC) → (empty).

The answer can be enormous, so compute the count modulo 998244353.

Constraints

2 \leq N \leq 10^7

N is an even number.

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of strings that satisfy the conditions, modulo 998244353.

Sample Input 1

2

Sample Output 1

7

Except AB and BA, all possible strings satisfy the conditions.

Sample Input 2

10

Sample Output 2

50007

Sample Input 3

1000000

Sample Output 3

210055358

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 998244353
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,k[10000005],kinv[10000005],inv[10000005],ans,sum;
ll cm(ll x,ll y){
	if(y<0||x<y)return 0;
	return k[x]*kinv[y]%M*kinv[x-y]%M;
}
int main(void){
	cin>>n;
    k[0]=1LL,inv[0]=1LL,inv[1]=1LL,kinv[0]=1LL;
    for(ll i=2;i<=n;i++)inv[i]=M-(M/i)*inv[M%i]%M;
    for(ll i=1;i<=n;i++)k[i]=k[i-1]*i%M,kinv[i]=kinv[i-1]*inv[i]%M;
    ans=1LL,sum=1LL;
    for(ll i=1;i<=n;i++){
		sum=sum*2LL%M;
		sum=(M+sum-cm(i-1LL,n/2LL)*2LL%M)%M;
		ans=(ans+sum*cm(n,i)%M)%M;
	}
	cout<<ans<<endl;
}