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>
using namespace std;
struct bian {
  int next, point;
} b[410000];
int len, p[210000], n, d[210000], root, mo = 1e9 + 7, A[210000], B[210000],
                                        C[210000], size[210000], f[210000];
vector<int> child[210000];
const int go[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
                      {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
void ade(int k1, int k2) {
  b[++len] = (bian){p[k1], k2};
  p[k1] = len;
}
void add(int k1, int k2) {
  ade(k1, k2);
  ade(k2, k1);
  d[k1]++;
  d[k2]++;
}
void dfs(int k1, int k2) {
  C[k1] = C[k2] + 1;
  size[k1] = 1;
  for (int i = p[k1]; i; i = b[i].next) {
    int j = b[i].point;
    if (j != k2) {
      child[k1].push_back(j);
      dfs(j, k1);
      A[k1] = max(A[k1], max(A[j], d[j]));
      if (B[k1] == 0) {
        if (d[j] == 3)
          B[k1] = j;
        else
          B[k1] = B[j];
      }
      size[k1] += size[j];
    }
  }
}
int dowith(int k1, int k2) {
  while (1) {
    if (child[k1].size() == 2 || child[k2].size() == 2) return 0;
    if (child[k1].size() == 0 && child[k2].size() == 0) return 1;
    if (child[k1].size() == 0) return f[child[k2][0]];
    if (child[k2].size() == 0) return f[child[k1][0]];
    k1 = child[k1][0];
    k2 = child[k2][0];
  }
}
void treedp(int k1, int k2) {
  for (int i = p[k1]; i; i = b[i].next) {
    int j = b[i].point;
    if (j != k2) treedp(j, k1);
  }
  if (size[k1] % 2) {
    f[k1] = 0;
    return;
  }
  if (B[k1] == 0 && d[k1] < 3) {
    f[k1] = size[k1] / 2;
    return;
  }
  if (child[k1].size() == 1) {
    int u = child[k1][0];
    if (d[u] == 1)
      f[k1] = 1;
    else if (d[u] == 2) {
      int v = child[u][0];
      f[k1] = f[v];
    }
  } else if (child[k1].size() == 2) {
    int k3 = child[k1][0], k4 = child[k1][1];
    if (child[k3].size() == 0)
      f[k1] = (f[k1] + f[k4]) % mo;
    else if (child[k3].size() == 1)
      f[k1] = (f[k1] + dowith(child[k3][0], k4)) % mo;
    swap(k3, k4);
    if (child[k3].size() == 0)
      f[k1] = (f[k1] + f[k4]) % mo;
    else if (child[k3].size() == 1)
      f[k1] = (f[k1] + dowith(child[k3][0], k4)) % mo;
    return;
  }
  if (B[k1] == 0 || B[k1] == -1) return;
  int u = B[k1], dis = C[u] - C[k1] + 1, k3 = child[u][0], k4 = child[u][1];
  if (size[k3] == dis && B[k3] == 0 && d[k3] != 3) f[k1] = (f[k1] + f[k4]) % mo;
  if (size[k4] == dis && B[k4] == 0 && d[k4] != 3) f[k1] = (f[k1] + f[k3]) % mo;
  if (size[k3] == dis - 2 && B[k3] == 0 && d[k3] != 3)
    f[k1] = (f[k1] + f[k4]) % mo;
  if (size[k4] == dis - 2 && B[k4] == 0 && d[k4] != 3)
    f[k1] = (f[k1] + f[k3]) % mo;
  if (d[k3] == 3) {
    int k5 = child[k3][0], k6 = child[k3][1];
    if (size[k5] == dis - 1 && B[k5] == 0 && d[k5] != 3)
      f[k1] = (f[k1] + dowith(k6, k4)) % mo;
    swap(k5, k6);
    if (size[k5] == dis - 1 && B[k5] == 0 && d[k5] != 3)
      f[k1] = (f[k1] + dowith(k6, k4)) % mo;
  }
  swap(k3, k4);
  if (d[k3] == 3) {
    int k5 = child[k3][0], k6 = child[k3][1];
    if (size[k5] == dis - 1 && B[k5] == 0 && d[k5] != 3)
      f[k1] = (f[k1] + dowith(k6, k4)) % mo;
    swap(k5, k6);
    if (size[k5] == dis - 1 && B[k5] == 0 && d[k5] != 3)
      f[k1] = (f[k1] + dowith(k6, k4)) % mo;
  }
  return;
}
int main() {
  scanf("%d", &n);
  n *= 2;
  if (n == 2) {
    cout << 2 << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    int k1, k2;
    scanf("%d%d", &k1, &k2);
    add(k1, k2);
  }
  int num = 0;
  for (int i = 1; i <= n; i++) num = max(num, d[i]);
  if (num > 3) {
    cout << 0 << endl;
    return 0;
  } else if (num == 2) {
    n = n / 2;
    cout << ((1ll * 2 * n * n % mo - 2 * n % mo + 4) % mo + mo) % mo << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (d[i] == 3) {
      root = i;
      break;
    }
  dfs(root, 0);
  for (int i = p[root]; i; i = b[i].next) {
    int j = b[i].point;
    treedp(j, root);
  }
  int ans = 0;
  for (int i = 0; i < 6; i++) {
    int k1 = child[root][go[i][0]], k2 = child[root][go[i][1]],
        k3 = child[root][go[i][2]];
    if (d[k1] == 1)
      ans = (ans + 1ll * f[k2] * f[k3]) % mo;
    else if (d[k1] == 2) {
      int k4 = child[k1][0];
      ans = (ans + 1ll * dowith(k2, k4) * f[k3]) % mo;
      ans = (ans + 1ll * dowith(k3, k4) * f[k2]) % mo;
    } else if (d[k1] == 3) {
      int k4 = child[k1][0], k5 = child[k1][1];
      ans = (ans + 1ll * dowith(k2, k4) * dowith(k3, k5)) % mo;
      ans = (ans + 1ll * dowith(k3, k4) * dowith(k2, k5)) % mo;
    }
  }
  cout << ans * 2 % mo << endl;
  return 0;
}