#include <bits/stdc++.h>
using namespace std;
const int N = 200005, P = 1000000007;
using ll = long long;
int n, rt, l[N], r[N], p[N], sz[N], d[N], f[N];
vector<int> v[N];
void dfs(int pos, int fa) {
  sz[pos] = 1;
  for (auto &i : v[pos]) {
    if (i == fa) continue;
    dfs(i, pos);
    p[pos] = p[i];
    sz[pos] += sz[i];
    d[pos] = d[i] + 1;
    if (!l[pos])
      l[pos] = i;
    else
      r[pos] = i;
  }
  if (r[pos]) p[pos] = pos, d[pos] = 0;
}
ll gg(int, int);
ll ff(int pos) {
  if (!pos) return 1;
  if (sz[pos] & 1) return 0;
  if (!p[pos]) return sz[pos] / 2;
  if (f[pos] > -1) return f[pos];
  int w = p[pos], x = l[w], y = r[w];
  ll ret = 0;
  auto upd = [&](int x, int y) {
    if (!r[y]) {
      if (d[pos] % 2 == 0 && sz[y] > 1) ret += gg(x, l[y]);
      if (!p[y] && d[y] <= d[pos] && (d[pos] + d[y]) % 2 == 0)
        ret += ff(x) * (d[pos] - d[y] >= 2 ? 2 : 1);
    } else {
      if (!p[l[y]] && d[l[y]] < d[pos] && (d[pos] + d[l[y]]) % 2)
        ret += gg(x, r[y]);
      if (!p[r[y]] && d[r[y]] < d[pos] && (d[pos] + d[r[y]]) % 2)
        ret += gg(x, l[y]);
    }
  };
  upd(x, y);
  upd(y, x);
  return f[pos] = ret % P;
}
ll gg(int x, int y) {
  if (!x || !y) return ff(x + y);
  if (r[x] || r[y]) return 0;
  if (l[x] && l[y]) return gg(l[x], l[y]);
  return ff(l[x] + l[y]);
}
int calc() {
  int mx = 0;
  for (int i = 1; i <= n * 2; i++)
    if (int(v[i].size()) > mx) mx = v[i].size(), rt = i;
  if (mx > 3) return 0;
  if (mx == 1) return 1;
  if (mx == 2) return (ll(n) * (n - 1) + 2) % P;
  ll ans = 0;
  dfs(rt, 0);
  memset(f, -1, sizeof(f));
  for (int i = 0; i < 6; i++) {
    int x = i / 2, y = (i + 3) % 6 / 2, z = 3 - x - y, t1, t2;
    x = v[rt][x];
    y = v[rt][y];
    z = v[rt][z];
    t1 = l[y];
    t2 = r[y];
    ans = (ans + gg(x, t1) * gg(z, t2) % P) % P;
    if (t1 || t2) ans = (ans + gg(x, t2) * gg(z, t1) % P) % P;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  int t1, t2;
  for (int i = 1; i < n * 2; i++)
    cin >> t1 >> t2, v[t1].push_back(t2), v[t2].push_back(t1);
  cout << calc() * 2 % P << endl;
  return 0;
}
