CSES - E4590 2016 2 - Tree matching
  • Time limit: 1.00 s
  • Memory limit: 512 MB

You are given a binary tree with nn nodes numbered 1,2,3,,n1, 2, 3, \ldots, n. The root of the tree is node 11. Your task is to determine how many ways there are to pair connected nodes so that each node is paired up with at most one another node.

As the number of ways may be large, output the result modulo 109+710^9+7.

Input

The first line of the input contains a single number, nn, the number of nodes in the tree.

Next nn lines each contain two integers, lil_i and rir_i, describing the left and right child of ithi^{th} node. lil_i is the index of left child of ithi^{th} node and rir_i is the index of right child of ithi^{th} node. Index 00 means that no node is connected as a child.

Output

A single line, result modulo 109+710^9+7.

Limits

  • 1n1061 \le n \le 10^6

Example

Input:

7
5 6
0 0
4 0
2 0
3 7
0 0
0 0

Output:

19

Explanation: