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;
bool debug = false;
const int N = 200010, MOD = 1e9 + 7.5;
int n, root;
int size[N], nearest3[N], depth[N];
vector<int> edges[N], child[N];
int f[N];
int add(int a, int b) { return (a + b) % MOD; }
int sub(int a, int b) { return (add(a, -b) + MOD) % MOD; }
int mul(int a, int b) { return (a * 1ll * b) % MOD; }
void bfs(int root) {
  vector<int> que, father;
  father.resize(n + 1), que.reserve(n);
  que.push_back(root), father[root] = 0, depth[root] = 0;
  for (int idx = 0; idx < ((int)(que).size()); ++idx) {
    int u = que[idx];
    for (int v : edges[u])
      if (father[u] != v)
        que.push_back(v), child[father[v] = u].push_back(v),
            depth[v] = depth[u] + 1;
  }
  for (int i = n - 1, u; i >= 0; --i) {
    nearest3[u = que[i]] = 0;
    for (int v : child[u])
      if (((int)(child[v]).size()) == 2)
        nearest3[u] = v;
      else if (nearest3[v])
        nearest3[u] = nearest3[v];
    size[father[u]] += ++size[u];
  }
  size[0] = 0;
}
int work2(int, int);
int work1(int u) {
  static struct INIT {
    INIT() { memset(f, 255, sizeof(f)); }
  } _INIT;
  if (u == 0) return 0;
  if (f[u] != -1) return f[u];
  f[u] = 0;
  if (((int)(child[u]).size()) == 1) {
    if (!nearest3[u]) return f[u] = size[u] / 2;
    int w = nearest3[u];
    if (depth[w] > depth[u] + 1) f[u] = add(f[u], work1(child[child[u][0]][0]));
    for (int t = 0; t < 2; ++t) {
      int c = child[w][t], space = depth[w] - depth[u] - 1;
      if (nearest3[c] || ((int)(child[c]).size()) > 1) continue;
      if (size[c] == space) f[u] = add(f[u], work1(child[w][t ^ 1]));
    }
    for (int t = 0; t < 2; ++t) {
      int c = child[w][t], c_ = child[w][t ^ 1],
          space = depth[w] - depth[u] + 1;
      if (((int)(child[c]).size()) == 1) {
        if (nearest3[c] || ((int)(child[c]).size()) > 1) continue;
        if (size[c] == space) f[u] = add(f[u], work1(c_));
      } else if (((int)(child[c]).size()) == 2) {
        for (int t = 0; t < 2; ++t) {
          int d = child[c][t], d_ = child[c][t ^ 1];
          if (((int)(child[d]).size()) > 1 || nearest3[d]) continue;
          if (size[d] == space - 1) f[u] = add(f[u], work2(c_, d_));
        }
      }
    }
  } else {
    for (int t = 0; t < 2; ++t) {
      int c = child[u][t], c_ = child[u][t ^ 1];
      if (!((int)(child[c]).size()))
        f[u] = add(f[u], work1(c_));
      else if (((int)(child[c]).size()) == 1)
        f[u] = add(f[u], work2(c_, child[c][0]));
    }
  }
  return f[u];
}
int work2(int a, int b) {
  if (!b) return work1(a);
  if (!a) return work1(b);
  int sa = ((int)(child[a]).size()), sb = ((int)(child[b]).size());
  if (sa == 2 || sb == 2) return 0;
  if (sa == 1 && sb == 1) return work2(child[a][0], child[b][0]);
  if (!sa && !sb) return 1;
  return ((int)(child[a]).size()) == 1 ? work1(child[a][0])
                                       : work1(child[b][0]);
}
void solve() {
  if (n == 1) {
    puts("2");
    return;
  }
  n <<= 1;
  int root = 1;
  for (int i = 1; i <= n; ++i)
    if (((int)(edges[i]).size()) > ((int)(edges[root]).size())) root = i;
  if (((int)(edges[root]).size()) > 3)
    puts("0");
  else if (((int)(edges[root]).size()) == 2)
    printf("%d\n", add(sub(mul(n >> 1, n), n), 4));
  else {
    bfs(root);
    vector<int> &son = child[root];
    sort(son.begin(), son.end());
    int ans = 0;
    do {
      if (((int)(child[son[2]]).size()) & 1) {
        int c = child[son[2]][0];
        for (int t = 0; t < 2; ++t) {
          if ((size[c] + size[son[t]]) & 1) continue;
          ans = add(ans, mul(work2(son[t], c), work1(son[t ^ 1])));
        }
      } else {
        for (int t = 0; t < 2; ++t) {
          int c = ((int)(child[son[2]]).size()) ? child[son[2]][t] : 0,
              c_ = ((int)(child[son[2]]).size()) ? child[son[2]][t ^ 1] : 0;
          if ((size[son[0]] + size[c]) & 1) continue;
          ans = add(ans, mul(work2(son[0], c), work2(son[1], c_)));
          if (!((int)(child[son[2]]).size())) break;
        }
      }
      if (debug) printf("%d %d\n", ans, ((int)(child[son[2]]).size()));
    } while (next_permutation(son.begin(), son.end()));
    printf("%d\n", mul(ans, 2));
    if (debug) {
      puts("YES");
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0, u, v; i < 2 * n - 1; ++i) {
    scanf("%d%d", &u, &v);
    edges[u].push_back(v), edges[v].push_back(u);
  }
  solve();
  return 0;
}