#P1762E. Tree Sum

Tree Sum

Description

Let us call an edge-weighted tree with nn vertices numbered from 11 to nn good if the weight of each edge is either 11 or 1-1 and for each vertex ii, the product of the edge weights of all edges having ii as one endpoint is 1-1.

You are given a positive integer nn. There are nn22n1n^{n-2} \cdot 2^{n-1} distinct^\dagger edge-weighted trees with nn vertices numbered from 11 to nn such that each edge is either 11 or 1-1. Your task is to find the sum of d(1,n)d(1,n)^\ddagger of all such trees that are good. Since the answer can be quite large, you only need to find it modulo 998244353998\,244\,353.

^\dagger Two trees are considered to be distinct if either:

  • there exists two vertices such that there is an edge between them in one of the trees, and not in the other.
  • there exists two vertices such that there is an edge between them in both trees but the weight of the edge between them in one tree is different from the one in the other tree.

Note that by Cayley's formula, the number of trees on nn labeled vertices is nn2n^{n-2}. Since we have n1n-1 edges, there are 2n12^{n-1} possible assignment of weights(weight can either be 11 or 1-1). That is why total number of distinct edge-weighted tree is nn22n1n^{n-2} \cdot 2^{n-1}.

^\ddagger d(u,v)d(u,v) denotes the sum of the weight of all edges on the unique simple path from uu to vv.

The first and only line of input contains a single integer nn (1n51051 \leq n \leq 5 \cdot 10^5).

The only line of output should contain a single integer, the required answer, modulo 998244353998\,244\,353.

Input

The first and only line of input contains a single integer nn (1n51051 \leq n \leq 5 \cdot 10^5).

Output

The only line of output should contain a single integer, the required answer, modulo 998244353998\,244\,353.

Sample Input 1

2

Sample Output 1

998244352

Sample Input 2

1

Sample Output 2

0

Sample Input 3

4

Sample Output 3

998244343

Sample Input 4

10

Sample Output 4

948359297

Sample Input 5

43434

Sample Output 5

86232114

Note

In the first test case, there is only 11 distinct good tree. The value of d(1,2)d(1,2) for that tree is 1-1, which is 998244352998\,244\,352 under modulo 998244353998\,244\,353.

In the second test case, the value of d(1,1)d(1,1) for any tree is 00, so the answer is 00.

In the third test case, there are 1616 distinct good trees. The value of d(1,4)d(1,4) is:

  • 2-2 for 22 trees;
  • 1-1 for 88 trees;
  • 00 for 44 trees;
  • 11 for 22 trees.

The sum of d(1,4)d(1,4) over all trees is 2(2)+8(1)+4(0)+2(1)=102 \cdot (-2) + 8 \cdot (-1) + 4 \cdot (0) + 2 \cdot (1) = -10, which is 998244343998\,244\,343 under modulo 998244353998\,244\,353.