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;
const int mod = 1000000007;
int n, a, b, c, root, d[200001], odw[200001], os3[200001], pre[200001],
    tp[200001];
long long ans, w[200001];
vector<int> s, v[200001];
int calc(int a, int b) {
  if (os3[a]) swap(a, b);
  if (os3[a]) return 0;
  if (!os3[b]) {
    if ((d[a] ^ d[b]) & 1) return 0;
    if (d[a] == d[b]) return 1;
    return abs(d[a] - d[b]) >> 1;
  } else {
    if (d[a] >= d[b]) return 0;
    int wr = tp[pre[os3[b]] - d[b] + d[a] + 1];
    return w[wr];
  }
}
void dfspom(int a) {
  odw[a] = 1;
  pre[a] = ++c;
  tp[c] = a;
  for (__typeof((v[a]).begin()) it = (v[a]).begin(); it != (v[a]).end(); ++it)
    if (!odw[*it]) dfspom(*it), os3[a] = os3[*it];
  if (v[a].size() == 3) os3[a] = a;
}
void dfswyn(int a) {
  odw[a] = 1;
  int s1 = 0, s2 = 0;
  s.push_back(a);
  for (__typeof((v[a]).begin()) it = (v[a]).begin(); it != (v[a]).end(); ++it)
    if (!odw[*it]) {
      dfswyn(*it);
      if (s1 == 0)
        s1 = *it;
      else
        s2 = *it;
    }
  if (a == root) return;
  int ojc = s[s.size() - 2];
  if (v[a].size() == 1) {
    if (v[ojc].size() < 3) w[ojc] = 1;
  } else if (v[a].size() == 2) {
    d[a] = d[s1] + 1;
    if (w[s1] && v[ojc].size() < 3) {
      w[ojc] += w[s1];
      if (!os3[a]) w[ojc]++;
      w[ojc] %= mod;
    }
  } else {
    if (os3[s1]) swap(s1, s2);
    if (!os3[s1]) {
      if (os3[s2]) {
        if (d[s1] < (int)s.size()) {
          if (d[s1] > 0) {
            int wcof = s[s.size() - d[s1] - 1];
            if (os3[wcof] == a) w[wcof] += w[s2], w[wcof] %= mod;
          }
          if (d[s1] + 2 < (int)s.size()) {
            int wcof = s[s.size() - d[s1] - 3];
            if (os3[wcof] == a) w[wcof] += w[s2], w[wcof] %= mod;
          }
        }
        if (d[s1] <= d[s2]) {
          int wr = tp[pre[os3[s2]] - d[s2] + d[s1]];
          w[a] += w[wr];
          if (d[s1] <= d[s2] - 2)
            wr = tp[pre[wr] + 2], w[a] += w[wr], w[a] %= mod;
        }
        if (os3[s2] == s2) {
          int ss1, ss2;
          if (v[s2][0] == a)
            ss1 = v[s2][1], ss2 = v[s2][2];
          else {
            ss1 = v[s2][0];
            if (v[s2][1] == a)
              ss2 = v[s2][2];
            else
              ss2 = v[s2][1];
          }
          if (!os3[ss1] && d[ss1] + 2 <= (int)s.size()) {
            int wcof = s[s.size() - d[ss1] - 2];
            if (os3[wcof] == a) w[wcof] += calc(s1, ss2);
            w[wcof] %= mod;
          }
          if (!os3[ss2] && d[ss2] + 2 <= (int)s.size()) {
            int wcof = s[s.size() - d[ss2] - 2];
            if (os3[wcof] == a) w[wcof] += calc(s1, ss1);
            w[wcof] %= mod;
          }
        }
      } else {
        if (d[s1] & 1) {
          int wcof;
          if (d[s2] > 0 && d[s2] < (int)s.size()) {
            wcof = s[s.size() - d[s2] - 1];
            if (os3[wcof] == a) w[wcof] += (d[s1] + 1) >> 1;
            w[wcof] %= mod;
          }
          if (d[s2] + 2 < (int)s.size()) {
            wcof = s[s.size() - d[s2] - 3];
            if (os3[wcof] == a) w[wcof] += (d[s1] + 1) >> 1;
            w[wcof] %= mod;
          }
        }
        if (d[s2] & 1) {
          int wcof;
          if (d[s1] > 0 && d[s1] < (int)s.size()) {
            wcof = s[s.size() - d[s1] - 1];
            if (os3[wcof] == a) w[wcof] += (d[s2] + 1) >> 1;
            w[wcof] %= mod;
          }
          if (d[s1] + 2 < (int)s.size()) {
            wcof = s[s.size() - d[s1] - 3];
            if (os3[wcof] == a) w[wcof] += (d[s2] + 1) >> 1;
            w[wcof] %= mod;
          }
        }
        if ((d[s1] ^ d[s2]) & 1)
          w[a] += max(2, abs(d[s1] - d[s2])), w[a] %= mod;
      }
    } else {
      int s11, s12;
      if (v[s1][0] == a)
        s11 = v[s1][1], s12 = v[s1][2];
      else {
        s11 = v[s1][0];
        if (v[s1][1] == a)
          s12 = v[s1][2];
        else
          s12 = v[s1][1];
      }
      if (!os3[s11] && !os3[s12]) {
        if (d[s11] < d[s2] && d[s12] + 2 <= (int)s.size()) {
          int wcof = s[s.size() - d[s12] - 2];
          if (os3[wcof] == a) {
            int wr = tp[pre[os3[s2]] - d[s2] + d[s11] + 1];
            w[wcof] += w[wr];
            w[wcof] %= mod;
          }
        }
        swap(s11, s12);
        if (d[s11] < d[s2] && d[s12] + 2 <= (int)s.size()) {
          int wcof = s[s.size() - d[s12] - 2];
          if (os3[wcof] == a) {
            int wr = tp[pre[os3[s2]] - d[s2] + d[s11] + 1];
            w[wcof] += w[wr];
            w[wcof] %= mod;
          }
        }
      }
      swap(s1, s2);
      if (v[s1][0] == a)
        s11 = v[s1][1], s12 = v[s1][2];
      else {
        s11 = v[s1][0];
        if (v[s1][1] == a)
          s12 = v[s1][2];
        else
          s12 = v[s1][1];
      }
      if (!os3[s11] && !os3[s12]) {
        if (d[s11] < d[s2] && d[s12] + 2 <= (int)s.size()) {
          int wcof = s[s.size() - d[s12] - 2];
          if (os3[wcof] == a) {
            int wr = tp[pre[os3[s2]] - d[s2] + d[s11] + 1];
            w[wcof] += w[wr];
            w[wcof] %= mod;
          }
        }
        swap(s11, s12);
        if (d[s11] < d[s2] && d[s12] + 2 <= (int)s.size()) {
          int wcof = s[s.size() - d[s12] - 2];
          if (os3[wcof] == a) {
            int wr = tp[pre[os3[s2]] - d[s2] + d[s11] + 1];
            w[wcof] += w[wr];
            w[wcof] %= mod;
          }
        }
      }
    }
  }
  s.pop_back();
}
int main() {
  scanf("%d", &n) ?: 0;
  for (int i = 0; i < (2 * n - 1); ++i)
    scanf("%d%d", &a, &b) ?: 0, v[a].push_back(b), v[b].push_back(a);
  if (n == 1) puts("2"), exit(0);
  for (int i = (1); i <= (n << 1); ++i) {
    if (v[i].size() > 3) puts("0"), exit(0);
    if (v[i].size() == 3) root = i;
  }
  if (root == 0) {
    ans = (4 + 2ll * n * (n - 1)) % mod;
    printf("%lld\n", ans);
    return 0;
  }
  dfspom(root);
  memset(odw + 1, 0, sizeof(long long) * n);
  dfswyn(root);
  for (int i = (1); i <= (n << 1); ++i) w[i] %= mod;
  sort((v[root]).begin(), (v[root]).end());
  do {
    int s1 = v[root][0], s2 = v[root][1], s3 = v[root][2];
    if (v[s2].size() == 1)
      ans += w[s1] * w[s3] % mod;
    else if (v[s2].size() == 2) {
      int ss1 = v[s2][0] == root ? v[s2][1] : v[s2][0];
      ans += calc(s1, ss1) * w[s3] % mod;
      ans += calc(s3, ss1) * w[s1] % mod;
    } else {
      int ss1, ss2;
      if (v[s2][0] == root)
        ss1 = v[s2][1], ss2 = v[s2][2];
      else {
        ss1 = v[s2][0];
        if (v[s2][1] == root)
          ss2 = v[s2][2];
        else
          ss2 = v[s2][1];
      }
      ans += (long long)calc(s1, ss1) * calc(s3, ss2) % mod;
      ans += (long long)calc(s3, ss1) * calc(s1, ss2) % mod;
    }
  } while (next_permutation((v[root]).begin(), (v[root]).end()));
  printf("%lld", 2ll * ans % mod);
}