Almost Euler graphs

Count the simple graphs on N labeled vertices that become Eulerian after adding or removing one edge, modulo 1e9+7.

Hard9CombinatoricsGraphMathDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

There is an undirected graph with NN vertices, numbered 00 through N1N-1. The graph is simple, so it has no loops, and at most one edge joins any two vertices.

A graph is an Euler graph if it is connected and it has a closed walk that uses every edge exactly once. A closed walk is a walk whose first and last vertices are the same. Connected here means that all NN vertices sit in one piece.

A graph is an almost Euler graph if adding one edge to it or removing one edge from it produces an Euler graph. When you add an edge, you may not create a loop and you may not add an edge that is already present. Every Euler graph is also an almost Euler graph.

Given NN, write a program that counts the distinct almost Euler graphs on NN vertices. Two graphs are distinct if some edge (i,j)(i, j) with 0i<jN10 \le i < j \le N-1 is present in one graph and absent from the other.

Input

The first line contains the number of vertices NN (2N20002 \le N \le 2000).

Output

Print the number of almost Euler graphs on NN vertices, modulo 1,000,000,007.