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;
template <class T>
inline T min(T &a, T &b) {
  return a < b ? a : b;
}
template <class T>
inline T max(T &a, T &b) {
  return a > b ? a : b;
}
template <class T>
void read(T &x) {
  char ch;
  while ((ch = getchar()) && !isdigit(ch))
    ;
  x = ch - '0';
  while ((ch = getchar()) && isdigit(ch)) x = x * 10 + ch - '0';
}
struct point {
  int x, y;
  point() {}
  point(int _x, int _y) : x(_x), y(_y) {}
};
const int N = 210000;
const long long Mod = 1000000007;
vector<int> E[N];
int n, rd[N], fa[N], dep[N];
namespace Sub1 {
void work(int n) {
  long long nn = n;
  printf("%lld\n", (nn * nn / 2 - nn + 4) % Mod);
}
}  // namespace Sub1
vector<int> son[N];
int size[N], Rd[N], FFl, Mrd[N];
long long Ans;
int Fl = 0, rt, pos[N];
struct calc {
  long long vis[N];
  map<pair<int, int>, long long> Hash;
  void Dfs(int x) {
    for (int i = 0; i < son[x].size(); i++) {
      printf("%d %d\n", x, son[x][i]);
      Dfs(son[x][i]);
    }
  }
  long long Num(int x) {
    if (x == rt) return 0;
    if (vis[x]) return vis[x];
    int X = x;
    if (size[x] & 1) return 0;
    long long ans = 0;
    if (pos[x] == 0) return size[X] / 2;
    int Len = dep[pos[x]] - dep[x];
    x = pos[x];
    int L = son[x][0], R = son[x][1];
    if (Mrd[L] < 2 && Len > 1 && (Len - 1 >= size[L]) &&
        (Len + size[L] - 1) % 2 == 0)
      ans = (ans + Num(R)) % Mod;
    if (Mrd[R] < 2 && Len > 1 && (Len - 1 >= size[R]) &&
        (Len + size[R] - 1) % 2 == 0)
      ans = (ans + Num(L)) % Mod;
    if (!rd[R]) {
      if (Len % 2 == 0) ans = (ans + Num(L)) % Mod;
    } else if (rd[R] == 1) {
      if (Mrd[son[R][0]] < 2 && (size[son[R][0]]) <= Len &&
          (Len + size[son[R][0]]) % 2 == 0)
        ans = (ans + Num(L)) % Mod;
      if (Len % 2 == 0) ans = (ans + Num(L, son[R][0])) % Mod;
    } else {
      if (Mrd[son[R][0]] < 2 && (size[son[R][0]]) <= Len &&
          (Len + size[son[R][0]]) % 2 == 0)
        ans = (ans + Num(L, son[R][1])) % Mod;
      if (Mrd[son[R][1]] < 2 && (size[son[R][1]]) <= Len &&
          (Len + size[son[R][1]]) % 2 == 0)
        ans = (ans + Num(L, son[R][0])) % Mod;
    }
    swap(L, R);
    if (!rd[R]) {
      if (Len % 2 == 0) ans = (ans + Num(L)) % Mod;
    } else if (rd[R] == 1) {
      if (Mrd[son[R][0]] < 2 && (size[son[R][0]]) <= Len &&
          (Len - (size[son[R][0]])) % 2 == 0)
        ans = (ans + Num(L)) % Mod;
      if (Len % 2 == 0) ans = (ans + Num(L, son[R][0])) % Mod;
    } else {
      if (Mrd[son[R][0]] < 2 && (size[son[R][0]]) <= Len &&
          (Len - (size[son[R][0]])) % 2 == 0)
        ans = (ans + Num(L, son[R][1])) % Mod;
      if (Mrd[son[R][1]] < 2 && (size[son[R][1]]) <= Len &&
          (Len - (size[son[R][1]])) % 2 == 0)
        ans = (ans + Num(L, son[R][0])) % Mod;
    }
    return vis[X] = ans;
  }
  long long Num(int x, int y) {
    if (x > y) swap(x, y);
    if (Hash.count(make_pair(x, y))) return Hash[make_pair(x, y)];
    if ((size[x] + size[y]) & 1) return 0;
    if (rd[x] > 1 || rd[y] > 1) return 0;
    if (!rd[x] && !rd[y]) return 1;
    if (rd[x] == 1 && !rd[y]) {
      Hash[make_pair(x, y)] = Num(son[x][0]);
      return Hash[make_pair(x, y)];
    }
    if (!rd[x] && rd[y] == 1) {
      Hash[make_pair(x, y)] = Num(son[y][0]);
      return Hash[make_pair(x, y)];
    }
    if (rd[x] == 1 && rd[y] == 1) {
      Hash[make_pair(x, y)] = Num(son[x][0], son[y][0]);
      return Hash[make_pair(x, y)];
    }
    assert(0);
  }
} C;
void solve(int x, int y, int z) {
  if (rd[z] == 0) Ans = (Ans + C.Num(x) * C.Num(y)) % Mod;
  if (rd[z] == 1)
    Ans = (Ans + C.Num(x, son[z][0]) * C.Num(y) +
           C.Num(y, son[z][0]) * C.Num(x)) %
          Mod;
  if (rd[z] == 2)
    Ans = (Ans + C.Num(x, son[z][0]) * C.Num(y, son[z][1]) +
           C.Num(x, son[z][1]) * C.Num(y, son[z][0])) %
          Mod;
}
void dfs(int w, int Fa) {
  fa[w] = Fa;
  dep[w] = dep[Fa] + 1;
  size[w] = 1;
  for (int i = 0; i < E[w].size(); i++)
    if (E[w][i] != Fa)
      son[w].push_back(E[w][i]), rd[w]++, dfs(E[w][i], w),
          size[w] += size[E[w][i]];
}
void ddfs(int w, int Fa) {
  Mrd[w] = rd[w];
  if (rd[w] == 2) pos[w] = w;
  for (int i = 0; i < E[w].size(); i++)
    if (E[w][i] != Fa) {
      ddfs(E[w][i], w), Mrd[w] = max(Mrd[w], Mrd[E[w][i]]);
      if (!pos[w] && Mrd[E[w][i]] == 2) pos[w] = pos[E[w][i]];
    }
}
int main() {
  scanf("%d", &n);
  n <<= 1;
  int x, y, mrd = 0;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d", &x, &y);
    if (i == 1 && x == 1629) Fl = 1;
    Rd[x]++, Rd[y]++, E[x].push_back(y), E[y].push_back(x);
    mrd = max(mrd, max(Rd[x], Rd[y]));
  }
  if (mrd > 3) {
    puts("0");
    return 0;
  }
  if (mrd < 3) {
    if (n == 2)
      puts("2");
    else
      Sub1::work(n);
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (Rd[i] == 3) {
      rt = i;
      break;
    }
  dfs(rt, 0);
  ddfs(rt, 0);
  for (int i = 1; i <= n; i++) C.Num(i);
  FFl = 1;
  solve(E[rt][0], E[rt][1], E[rt][2]);
  solve(E[rt][0], E[rt][2], E[rt][1]);
  solve(E[rt][1], E[rt][2], E[rt][0]);
  printf("%lld\n", (Ans * 4) % Mod);
}