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;
using namespace rel_ops;
using ll = int64_t;
using Pii = pair<int, int>;
using ull = uint64_t;
using Vi = vector<int>;
void run();
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  run();
  return 0;
}
int uplg(int n) { return 32 - __builtin_clz(n); }
int uplg(ll n) { return 64 - __builtin_clzll(n); }
constexpr ll MOD = 1e9 + 7;
struct Zp {
  ll first;
  Zp(ll a = 0) {
    if (a < 0)
      a = a % MOD + MOD;
    else if (a >= MOD * 2)
      a %= MOD;
    else if (a >= MOD)
      a -= MOD;
    first = a;
  }
  Zp operator+(Zp r) const { return first + r.first; }
  Zp operator-(Zp r) const { return first - r.first + MOD; }
  Zp operator*(Zp r) const { return first * r.first; }
  Zp operator/(Zp r) const { return first * r.inv().first; }
  Zp operator-() const { return MOD - first; }
  Zp inv() const { return pow(MOD - 2); }
  Zp pow(ll e) const {
    Zp t = 1, m = *this;
    while (e) {
      if (e & 1) t *= m;
      e >>= 1;
      m *= m;
    }
    return t;
  }
  Zp& operator+=(Zp r) { return *this = *this + r; }
  Zp& operator-=(Zp r) { return *this = *this - r; }
  Zp& operator*=(Zp r) { return *this = *this * r; }
  Zp& operator/=(Zp r) { return *this = *this / r; }
  void print() { cerr << first; }
};
constexpr int LOG_N = 17;
struct Vert {
  vector<Pii> E;
  array<array<Pii, LOG_N + 1>, 3> jump;
  array<Pii, 3> last;
  array<int, 3> len, size = {0, 0, 0};
  array<Zp, 3> f;
};
vector<Vert> G;
int h(int n) {
  if (n < 0 || n % 2) return 0;
  if (n == 0) return 1;
  return n / 2;
}
bool g(int L, int k) { return L > k && (L - k) % 2; }
Pii son(int v, int p, int d) {
  for (int i = LOG_N; i >= 0; i--) {
    int j = 1 << i;
    if (j <= d) {
      tie(v, p) = G[v].jump[p][i];
      d -= j;
    }
  }
  return {v, p};
}
int countChildren(int v, int p) {
  return int((G[v].E).size()) - (p < int((G[v].E).size()));
}
void getChildren(int v, int p, Pii& first, Pii& second) {
  first = second = {-1, -1};
  for (int i = (0); i < (int((G[v].E).size())); i++)
    if (i != p) {
      (first.first == -1 ? first : second) = G[v].E[i];
    }
}
void compute(int v, int p) {
  if (G[v].size[p] > 0) return;
  auto& jump = G[v].jump[p];
  Pii& u = G[v].last[p] = {v, p};
  int& size = G[v].size[p] = 1;
  int& len = G[v].len[p] = 1;
  Zp& f = G[v].f[p] = 0;
  int nChildren = 0;
  Pii lastChild;
  for (int i = (0); i < (int((G[v].E).size())); i++)
    if (i != p) {
      Pii e = G[v].E[i];
      compute(e.first, e.second);
      size += G[e.first].size[e.second];
      lastChild = e;
      nChildren++;
    }
  if (nChildren == 1) {
    len += G[lastChild.first].len[lastChild.second];
    u = G[lastChild.first].last[lastChild.second];
    jump[0] = lastChild;
    for (int i = (1); i < (LOG_N + 1); i++) {
      jump[i] = jump[i - 1];
      if (jump[i].first != -1) {
        jump[i] = G[jump[i].first].jump[jump[i].second][i - 1];
      }
    }
  } else {
    fill((jump).begin(), (jump).end(), make_pair(-1, -1));
  }
  if (size % 2) return;
  Pii first, second;
  getChildren(u.first, u.second, first, second);
  if (second.first == -1) {
    f = h(len);
    return;
  }
  int l1 = G[first.first].len[first.second],
      l2 = G[second.first].len[second.second];
  Pii lx = G[first.first].last[first.second],
      ly = G[second.first].last[second.second];
  bool chain1 = (countChildren(lx.first, lx.second) == 0);
  bool chain2 = (countChildren(ly.first, ly.second) == 0);
  if (chain1 && chain2) {
    if (l1 > 1 && g(len, l1 - 1)) f += G[second.first].f[second.second];
    if (l2 > 1 && g(len, l2 - 1)) f += G[first.first].f[first.second];
    if (g(len - 1, l1)) f += G[second.first].f[second.second];
    if (g(len - 1, l2)) f += G[first.first].f[first.second];
    if (g(len, 0)) {
      f += h(G[u.first].size[u.second] - 2 * min(l1 + 1, l2));
      f += h(G[u.first].size[u.second] - 2 * min(l1, l2 + 1));
    }
    return;
  }
  if (chain2) {
    swap(first, second);
    swap(l1, l2);
    swap(lx, ly);
    swap(chain1, chain2);
  }
  if (!chain1) {
    if (second.first == ly.first) {
      swap(first, second);
      swap(l1, l2);
      swap(lx, ly);
      swap(chain1, chain2);
    }
    if (first.first != lx.first) return;
    Pii a, b;
    getChildren(first.first, first.second, a, b);
    int l3 = G[a.first].len[a.second], l4 = G[b.first].len[b.second];
    Pii la = G[a.first].last[a.second], lb = G[b.first].last[b.second];
    if (countChildren(la.first, la.second) > 0 ||
        countChildren(lb.first, lb.second)) {
      return;
    }
    if (l4 < l2 && g(len, l3)) {
      Pii an = son(second.first, second.second, l4);
      f += G[an.first].f[an.second];
    }
    if (l3 < l2 && g(len, l4)) {
      Pii an = son(second.first, second.second, l3);
      f += G[an.first].f[an.second];
    }
    return;
  }
  if (l2 > 1) {
    if (l1 > 1 && g(len, l1 - 1)) f += G[second.first].f[second.second];
    if (g(len - 1, l1)) f += G[second.first].f[second.second];
    if (g(len, 0)) {
      if (l1 < l2 + 1) {
        Pii a = son(second.first, second.second, l1 - 1);
        f += G[a.first].f[a.second];
      }
      if (l1 + 1 < l2) {
        Pii a = son(second.first, second.second, l1 + 1);
        f += G[a.first].f[a.second];
      }
    }
    return;
  }
  Pii z, w;
  getChildren(second.first, second.second, z, w);
  l2 = G[z.first].len[z.second];
  int l3 = G[w.first].len[w.second];
  Pii lz = G[z.first].last[z.second], lw = G[w.first].last[w.second];
  chain1 = (countChildren(lz.first, lz.second) == 0);
  chain2 = (countChildren(lw.first, lw.second) == 0);
  if (chain2) {
    swap(z, w);
    swap(l2, l3);
    swap(lz, lw);
    swap(chain1, chain2);
  }
  if (!chain1) return;
  if (g(len, l1 - 1)) f += G[second.first].f[second.second];
  if (g(len - 1, l1)) f += G[second.first].f[second.second];
  if (chain2) {
    if (g(len, l2))
      f += h(G[first.first].size[first.second] + G[w.first].size[w.second] -
             2 * min(l1, l3));
    if (g(len, l3))
      f += h(G[first.first].size[first.second] + G[z.first].size[z.second] -
             2 * min(l1, l2));
  } else if (l1 < l3 && g(len, l2)) {
    Pii a = son(w.first, w.second, l1);
    f += G[a.first].f[a.second];
  }
}
void printRooted(int v, int p = 2) {
  ;
  for (int i = (0); i < (int((G[v].E).size())); i++)
    if (i != p) {
      Pii e = G[v].E[i];
      printRooted(e.first, e.second);
    }
}
void run() {
  int n;
  cin >> n;
  G.resize(2 * n);
  for (int i = (0); i < (2 * n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].E.push_back({b, int((G[b].E).size())});
    G[b].E.push_back({a, int((G[a].E).size()) - 1});
  }
  for (auto& v : (G)) {
    if (int((v.E).size()) > 3) {
      cout << 0 << endl;
      return;
    }
  }
  Zp ans = 0;
  for (int i = (0); i < (int((G).size())); i++) {
    if (int((G[i].E).size()) <= 2) {
      compute(i, 2);
      ans += G[i].f[2];
    }
  }
  cout << ans.first << endl;
}