#P1762E. Tree Sum
Tree Sum
Description
Let us call an edge-weighted tree with vertices numbered from to good if the weight of each edge is either or and for each vertex , the product of the edge weights of all edges having as one endpoint is .
You are given a positive integer . There are distinct edge-weighted trees with vertices numbered from to such that each edge is either or . Your task is to find the sum of of all such trees that are good. Since the answer can be quite large, you only need to find it modulo .
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 labeled vertices is . Since we have edges, there are possible assignment of weights(weight can either be or ). That is why total number of distinct edge-weighted tree is .
denotes the sum of the weight of all edges on the unique simple path from to .
The first and only line of input contains a single integer ().
The only line of output should contain a single integer, the required answer, modulo .
Input
The first and only line of input contains a single integer ().
Output
The only line of output should contain a single integer, the required answer, modulo .
Note
In the first test case, there is only distinct good tree. The value of for that tree is , which is under modulo .
In the second test case, the value of for any tree is , so the answer is .
In the third test case, there are distinct good trees. The value of is:
- for trees;
- for trees;
- for trees;
- for trees.
The sum of over all trees is , which is under modulo .