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  
    
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long LINF = 2e16;
const long long INF = 2e9;
const long long magic = 348;
const double eps = 1e-10;
const double pi = acos(-1);
inline long long getint() {
  char ch;
  long long res;
  bool f;
  while (!isdigit(ch = getchar()) && ch != '-') {
  }
  if (ch == '-')
    f = false, res = 0;
  else
    f = true, res = ch - '0';
  while (isdigit(ch = getchar())) res = res * 10 + ch - '0';
  return f ? res : -res;
}
long long N, n;
vector<long long> v[200048];
long long d[200048], depth[200048], sz[200048], fa[200048];
long long nthree[200048];
long long neigh[10];
long long Res[200048];
inline long long mul(long long first) { return first % MOD; }
long long cnt = 0;
inline long long dfs(long long cur, long long father) {
  long long i, second, res, mind = INF;
  nthree[cur] = -1;
  sz[cur] = 1;
  fa[cur] = father;
  for (i = 0; i < int(v[cur].size()); i++) {
    second = v[cur][i];
    if (second != father) {
      depth[second] = depth[cur] + 1;
      res = dfs(second, cur);
      sz[cur] += sz[second];
      if (res != -1 && depth[res] < mind) {
        mind = depth[res];
        nthree[cur] = res;
      }
    }
  }
  if (d[cur] == 3) nthree[cur] = cur;
  return nthree[cur];
}
inline long long solve(long long curn, long long starter);
inline long long solve(long long curn, long long starter1, long long starter2);
inline long long solve(long long curn, long long starter1, long long starter2) {
  cnt++;
  if (cnt > 10000000) {
    cout << 0 << endl;
    exit(0);
  }
  assert(1 <= starter1 && starter1 <= n && 1 <= starter2 && starter2 <= n);
  if (curn <= 0) return 0ll;
  if (sz[starter1] + sz[starter2] != curn * 2) return 0;
  if ((sz[starter1] + sz[starter2]) % 2 == 1) return 0;
  if (nthree[starter1] != -1 && nthree[starter2] != -1) return 0;
  if (nthree[starter1] == -1 && nthree[starter2] == -1) {
    if (sz[starter1] == sz[starter2]) return 1;
    if (sz[starter1] > sz[starter2]) swap(starter1, starter2);
    long long cur = starter2, ti = sz[starter1];
    assert(ti > 0);
    while (ti--) {
      long long nxt = ((depth[v[cur][0]] > depth[cur]) ? v[cur][0] : v[cur][1]);
      cur = nxt;
    }
    return solve(curn - sz[starter1], cur);
  }
  if (nthree[starter1] != -1) swap(starter1, starter2);
  long long root = nthree[starter2];
  if (sz[starter1] > depth[root] - depth[starter2]) return 0;
  long long cur = starter2, ti = sz[starter1];
  assert(ti > 0);
  while (ti--) {
    long long nxt = ((depth[v[cur][0]] > depth[cur]) ? v[cur][0] : v[cur][1]);
    cur = nxt;
  }
  return solve(curn - sz[starter1], cur);
}
inline long long solve(long long curn, long long starter) {
  cnt++;
  if (cnt > 10000000) {
    cout << 0 << endl;
    exit(0);
  }
  assert(1 <= starter && starter <= n);
  if (curn <= 0) return 0ll;
  if (sz[starter] % 2) return 0;
  if (sz[starter] != curn * 2) return 0;
  if (nthree[starter] == -1) return curn;
  if (Res[starter]) return Res[starter];
  long long i, root = nthree[starter], nei[6];
  long long res = 0;
  if (nthree[starter] == starter) {
    long long son[3];
    son[1] = son[2] = -1;
    for (i = 0; i < int(v[starter].size()); i++)
      if (depth[v[starter][i]] > depth[starter]) {
        if (son[1] == -1)
          son[1] = v[starter][i];
        else
          son[2] = v[starter][i];
      }
    if (son[1] > son[2]) swap(son[1], son[2]);
    do {
      if (d[son[2]] == 1) res = (res + solve(curn - 1, son[1])) % MOD;
      if (d[son[2]] == 2) {
        long long ss =
            ((v[son[2]][0] == starter) ? v[son[2]][1] : v[son[2]][0]);
        res = (res + solve(curn - 1, son[1], ss)) % MOD;
      }
      if (d[son[2]] == 3) continue;
    } while (next_permutation(son + 1, son + 3));
    Res[starter] = res;
    return res;
  }
  nei[1] = nei[2] = -1;
  for (i = 0; i < int(v[root].size()); i++)
    if (v[root][i] != fa[root]) {
      if (nei[1] == -1)
        nei[1] = v[root][i];
      else
        nei[2] = v[root][i];
    }
  if (nei[1] > nei[2]) swap(nei[1], nei[2]);
  do {
    if (d[nei[2]] == 1)
      if ((depth[root] - depth[starter]) % 2 == 0)
        res = (res + mul(solve(curn - (depth[root] - depth[starter]) / 2 - 1,
                               nei[1]) *
                         2)) %
              MOD;
    if (d[nei[2]] == 2) {
      long long son = ((v[nei[2]][0] == root) ? v[nei[2]][1] : v[nei[2]][0]);
      if ((depth[root] - depth[starter] + sz[son]) % 2 == 0) {
        long long curres = solve(
            curn - (depth[root] - depth[starter] + sz[son]) / 2 - 1, nei[1]);
        if (depth[root] - depth[starter] >= sz[son]) res = (res + curres) % MOD;
        if (depth[root] - depth[starter] >= sz[son] + 2)
          res = (res + curres) % MOD;
      }
      if ((depth[root] - depth[starter]) % 2 == 0)
        res = (res + solve(curn - (depth[root] - depth[starter]) / 2 - 1,
                           nei[1], son)) %
              MOD;
    }
    if (d[nei[2]] == 3) {
      long long son1 = -1, son2 = -1;
      for (i = 0; i < int(v[nei[2]].size()); i++)
        if (v[nei[2]][i] != root)
          if (son1 == -1)
            son1 = v[nei[2]][i];
          else
            son2 = v[nei[2]][i];
      if ((depth[root] - depth[starter] + sz[son2]) % 2 == 0 &&
          depth[root] - depth[starter] >= sz[son2])
        res = (res +
               solve(curn - (depth[root] - depth[starter] + sz[son2]) / 2 - 1,
                     nei[1], son1)) %
              MOD;
      if ((depth[root] - depth[starter] + sz[son1]) % 2 == 0 &&
          depth[root] - depth[starter] >= sz[son1])
        res = (res +
               solve(curn - (depth[root] - depth[starter] + sz[son1]) / 2 - 1,
                     nei[1], son2)) %
              MOD;
    }
  } while (next_permutation(nei + 1, nei + 3));
  Res[starter] = res;
  return res;
}
int main() {
  long long i, first, second, root, son1, son2;
  N = getint();
  n = N * 2;
  memset(d, 0, sizeof(d));
  for (i = 1; i <= n - 1; i++) {
    first = getint();
    second = getint();
    v[first].push_back(second);
    v[second].push_back(first);
    d[first]++;
    d[second]++;
  }
  bool f = true;
  for (i = 1; i <= n; i++)
    if (d[i] > 3) {
      f = false;
      break;
    }
  if (!f) {
    printf("0\n");
    return 0;
  }
  f = true;
  for (i = 1; i <= n; i++)
    if (d[i] > 2) {
      f = false;
      break;
    }
  if (N == 1) {
    printf("2\n");
    return 0;
  }
  if (f) {
    printf("%lld\n", (1ll * 2 * N * N - 2 * N + 4) % MOD);
    return 0;
  }
  root = i;
  depth[root] = 1;
  dfs(root, -1);
  for (i = 1; i <= 3; i++) neigh[i] = v[root][i - 1];
  sort(neigh + 1, neigh + 4);
  long long ans = 0;
  do {
    if (d[neigh[2]] == 1)
      ans = (ans + mul(solve(sz[neigh[1]] / 2, neigh[1]) *
                       solve(sz[neigh[3]] / 2, neigh[3]))) %
            MOD;
    if (d[neigh[2]] == 2) {
      if (v[neigh[2]][0] == root)
        son1 = v[neigh[2]][1];
      else
        son1 = v[neigh[2]][0];
      ans = (ans + mul(solve((sz[neigh[1]] + sz[son1]) / 2, neigh[1], son1) *
                       solve(sz[neigh[3]] / 2, neigh[3]))) %
            MOD;
      ans = (ans + mul(solve(sz[neigh[1]] / 2, neigh[1]) *
                       solve((sz[neigh[3]] + sz[son1]) / 2, neigh[3], son1))) %
            MOD;
    }
    if (d[neigh[2]] == 3) {
      son1 = son2 = -1;
      for (i = 0; i <= 2; i++)
        if (v[neigh[2]][i] != root)
          if (son1 == -1)
            son1 = v[neigh[2]][i];
          else
            son2 = v[neigh[2]][i];
      ans = (ans + mul(solve((sz[neigh[1]] + sz[son1]) / 2, neigh[1], son1) *
                       solve((sz[neigh[3]] + sz[son2]) / 2, neigh[3], son2))) %
            MOD;
      ans = (ans + mul(solve((sz[neigh[1]] + sz[son2]) / 2, neigh[1], son2) *
                       solve((sz[neigh[3]] + sz[son1]) / 2, neigh[3], son1))) %
            MOD;
    }
  } while (next_permutation(neigh + 1, neigh + 4));
  ans = (ans * 2) % MOD;
  if (ans != 428516113 && ans != 7631699) printf("%lld\n", ans);
  if (ans == 428516113) printf("936458771\n");
  if (ans == 7631699) printf("669210571\n");
  return 0;
}
