Problem: Little Petya likes trees a lot. Recently his mother has presented him a tree with 2n nodes. Petya immediately decided to place this tree on a rectangular table consisting of 2 rows and n columns so as to fulfill the following conditions:

  1. Each cell of the table corresponds to exactly one tree node and vice versa, each tree node corresponds to exactly one table cell. 
  2. If two tree nodes are connected by an edge, then the corresponding cells have a common side. 



Now Petya wonders how many ways are there to place his tree on the table. He calls two placements distinct if there is a tree node which corresponds to distinct table cells in these two placements. Since large numbers can scare Petya, print the answer modulo 1000000007 (109 + 7).

Input

The first line contains a single integer n (1 ≤ n ≤ 105). Next (2n - 1) lines contain two integers each ai and bi (1 ≤ ai, bi ≤ 2n; ai ≠ bi) that determine the numbers of the vertices connected by the corresponding edge. 

Consider the tree vertexes numbered by integers from 1 to 2n. It is guaranteed that the graph given in the input is a tree, that is, a connected acyclic undirected graph.

Output

Print a single integer — the required number of ways to place the tree on the table modulo 1000000007 (109 + 7).

Examples

Input

3
1 3
2 3
4 3
5 1
6 2


Output

12


Input

4
1 2
2 3
3 4
4 5
5 6
6 7
7 8


Output

28


Input

2
1 2
3 2
4 2


Output

0

Note

Note to the first sample (all 12 variants to place the tree on the table are given below):
    
    
      
    1-3-2    2-3-1    5 4 6    6 4 5  
    | | |    | | |    | | |    | | |  
    5 4 6    6 4 5    1-3-2    2-3-1  
      
    4-3-2    2-3-4    5-1 6    6 1-5  
      | |    | |        | |    | |  
    5-1 6    6 1-5    4-3-2    2-3-4  
      
    1-3-4    4-3-1    5 2-6    6-2 5  
    | |        | |    | |        | |  
    5 2-6    6-2 5    1-3-4    4-3-1  
    

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
int a, b, c, d, i, j, n, m, k;
vector<int> sm[200002];
int dp[200002], next3[200002], h[200002], cs[200002];
void dfs(int v, int pr = -1) {
  cs[v] = 1;
  int i = 0;
  while (i < (int)((sm[v]).size())) {
    int w = sm[v][i];
    if (w == pr) {
      swap(sm[v][i], sm[v].back());
      sm[v].pop_back();
      continue;
    }
    h[w] = h[v] + 1;
    dfs(w, v);
    cs[v] += cs[w];
    next3[v] = next3[w];
    ++i;
  }
  if (pr == -1 || (int)((sm[v]).size()) == 2) next3[v] = v;
}
int get_down(int v, int c) {
  if (!c) return v;
  return get_down(sm[v][0], c - 1);
}
int rec(int v, bool root = false);
int rec2(int v1, int v2) {
  if ((int)((sm[v1]).size()) == 0 && (int)((sm[v2]).size()) == 0) return 1;
  if (next3[v1] != -1 && next3[v2] != -1) return 0;
  if (cs[v1] > cs[v2]) swap(v1, v2);
  if (next3[v1] != -1) return 0;
  if (next3[v2] != -1) {
    int down2 = h[next3[v2]] - h[v2];
    int down1 = cs[v1] - 1;
    if (down1 >= down2) return 0;
  }
  if (cs[v1] == cs[v2] && next3[v1] == -1 && next3[v2] == -1) return 1;
  return rec(get_down(v2, cs[v1]));
}
int check(int v, int w, int left) {
  if (next3[left] != -1) return 0;
  int cnt = h[w] - h[v];
  if ((cnt + cs[left]) % 2) return 0;
  if (cs[left] > cnt) return 0;
  return 1;
}
int check2(int v, int w) {
  int cnt = h[w] - h[v];
  if (cnt % 2) return 0;
  return 1;
}
int check3(int v, int w, int left) {
  if (next3[left] != -1) return 0;
  int cnt = h[w] - h[v];
  if (cs[left] >= cnt) return 0;
  if ((cnt - cs[left] - 1) % 2 == 1) return 0;
  return 1;
}
int rec(int v, bool root) {
  if (root) {
    vector<int> ind;
    for (int _n((3) - 1), i(0); i <= _n; i++) ind.push_back(i);
    int ans = 0;
    do {
      int left = sm[v][ind[0]];
      int middle = sm[v][ind[1]];
      int right = sm[v][ind[2]];
      if ((int)((sm[middle]).size()) == 0) {
        ans = (ans + (long long)rec(left) * rec(right)) % 1000000007;
      }
      if ((int)((sm[middle]).size()) == 1) {
        ans = (ans + (long long)rec(left) * rec2(right, sm[middle][0])) %
              1000000007;
        ans = (ans + (long long)rec2(left, sm[middle][0]) * rec(right)) %
              1000000007;
      }
      if ((int)((sm[middle]).size()) == 2) {
        ans = (ans + (long long)rec2(left, sm[middle][0]) *
                         rec2(right, sm[middle][1])) %
              1000000007;
        ans = (ans + (long long)rec2(left, sm[middle][1]) *
                         rec2(right, sm[middle][0])) %
              1000000007;
      }
    } while (next_permutation((ind).begin(), (ind).end()));
    return ans;
  }
  if (dp[v] != -1) return dp[v];
  if (cs[v] % 2 == 1) return dp[v] = 0;
  if (cs[v] == 2) return dp[v] = 1;
  int ans = 0;
  if (next3[v] == -1) return cs[v] / 2;
  if ((int)((sm[v]).size()) == 1) {
    int w = next3[v];
    for (int _n((2) - 1), i(0); i <= _n; i++) {
      int down = sm[w][i];
      int right = sm[w][i ^ 1];
      if ((int)((sm[down]).size()) == 0) {
        if (check2(v, w)) ans = (ans + rec(right)) % 1000000007;
      } else if ((int)((sm[down]).size()) == 1) {
        if (check2(v, w)) ans = (ans + rec2(right, sm[down][0])) % 1000000007;
        if (check(v, w, sm[down][0])) ans = (ans + rec(right)) % 1000000007;
      } else if ((int)((sm[down]).size()) == 2) {
        if (check(v, w, sm[down][0]))
          ans = (ans + rec2(right, sm[down][1])) % 1000000007;
        if (check(v, w, sm[down][1]))
          ans = (ans + rec2(right, sm[down][0])) % 1000000007;
      }
      int left = down;
      if (check3(v, w, left)) ans = (ans + rec(right)) % 1000000007;
    }
    return dp[v] = ans;
  }
  for (int _n((2) - 1), i(0); i <= _n; i++) {
    int w = sm[v][i];
    int o = sm[v][i ^ 1];
    if ((int)((sm[w]).size()) == 2) continue;
    if ((int)((sm[w]).size()) == 0)
      ans = (ans + rec(o)) % 1000000007;
    else
      ans = (ans + rec2(o, sm[w][0])) % 1000000007;
  }
  return dp[v] = ans;
}
int solve() {
  int root = -1;
  for (int _n((m)-1), i(0); i <= _n; i++) {
    if ((int)((sm[i]).size()) > 3) return 0;
    if ((int)((sm[i]).size()) == 3) root = i;
  }
  if (root == -1) {
    if (n == 1)
      return ((long long)n * n - n + 2) % 1000000007;
    else
      return ((long long)n * n - n + 2) * 2 % 1000000007;
  }
  h[root] = 0;
  memset(next3, -1, m * sizeof(int));
  dfs(root);
  memset(dp, -1, m * sizeof(int));
  return 2LL * rec(root, 1) % 1000000007;
}
int main() {
  scanf("%d", &n);
  m = 2 * n;
  for (int _n((m - 1) - 1), i(0); i <= _n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    sm[a].push_back(b);
    sm[b].push_back(a);
  }
  printf("%d\n", solve());
}