Embedding Enumeration

Count the ways to place a labeled tree's nodes into a 2 by n grid so node 1 sits at the top-left, edges touch, and no cell repeats, modulo 1e9+7.

Hard8TreeDFSDynamic programmingCombinatoricsNo attempts yetTime limit4sMemory limit512 MB

Problem

A tree is a graph with nn nodes and n1n-1 undirected edges in which every two nodes are joined by exactly one path. In a labeled tree every node carries a different integer between 1 and nn. Drawing a tree neatly is hard in general, but some trees fit into a rectangular grid.

Let GG be a labeled tree with nn nodes. A 2×n2 \times n embedding of GG maps the nodes of GG to the cells of a grid with 2 rows and nn columns so that all three conditions hold.

  • Node 1 maps to the cell in the upper left corner.
  • Two nodes joined by an edge map to two cells that touch up, down, left or right.
  • No two nodes map to the same cell.

Count the 2×n2 \times n embeddings of the given tree, modulo 109+710^9 + 7.

Input

The first line contains the number of nodes nn of GG (1n3000001 \le n \le 300\,000).

The jj-th of the next n1n-1 lines contains the two endpoints aja_j and bjb_j of the jj-th edge (1aj,bjn1 \le a_j, b_j \le n, ajbja_j \ne b_j).

The given graph is always a tree.

Output

Print the number of 2×n2 \times n embeddings of the given tree, modulo 109+710^9 + 7.

Note

The figure above draws all 4 embeddings of the tree in the first example.