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 PyPy3 (2.4.0) (judge verdict: Time Limit Exceeded)

N = int(input())
MOD = 998244353
def func(x):
    a = [23,26]
    out = 1
    for i in range(30):
        if not i in a:
            out = (out*x)%MOD
        x *= x
        x %= MOD
    return out

def func2(x):
    x = bin(x)[2:]
    out = 1
    b = 3
    for i in range(len(x)):
        if x[-1-i] == "1":
            out *= b
            out %= MOD
        b *= b
        b %= MOD
    return out

ans = 0
d = 1
b = 1
for i in range((N//2)):
    ans += d * b
    b *= 2
    b %= MOD
    ans %= MOD
    d = ((N-i)*d)%MOD
    d = (d*func(i+1))%MOD

print((func2(N)-ans*2)%MOD)