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 Rust (1.15.1) (judge verdict: Wrong Answer)

// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    const M: i64 = 998244353;
    let mut ans = modpow(3, n, M);
    let mb = ModBinomial::new(n+1, M);
    for k in 1 .. n {
        if k % 2 == 1 {
            ans = (ans - mb.bin(n, k) + M) % M;
        }
    }
    println!("{}", ans);
}

fn modpow(x: i64, p: i64, m: i64) -> i64 {
    if p == 0 {
        1
    } else if p % 2 == 0 {
        modpow((x * x) % m, p / 2, m)
    } else {
        (x * modpow(x, p - 1, m)) % m 
    }
}
struct ModBinomial { m: i64, f: Vec<i64>, p: Vec<i64> }
impl ModBinomial {
    fn new(n: i64, m: i64) -> ModBinomial {
        let mut f = vec![1; n as usize + 1];
        let mut p = vec![1; f.len()];
        for i in 2..f.len() {
            f[i] = (i as i64 * f[i - 1]) % m;
            p[i] = modpow(f[i], m - 2, m);
        }
        ModBinomial { m: m, f: f, p: p }
    }
    fn bin(&self, n: i64, k: i64) -> i64 {
        (((self.f[n as usize] * self.p[k as usize])
            % self.m) * self.p[(n - k) as usize]) % self.m
    }
}