#include <bits/stdc++.h>
using namespace std;
bool debug = false;
const int N = 200010, MOD = 1e9 + 7.5;
int n, root;
int size[N], nearest3[N], depth[N];
vector<int> edges[N], child[N];
int f[N];
int add(int a, int b) { return (a + b) % MOD; }
int sub(int a, int b) { return (add(a, -b) + MOD) % MOD; }
int mul(int a, int b) { return (a * 1ll * b) % MOD; }
void bfs(int root) {
  vector<int> que, father;
  father.resize(n + 1), que.reserve(n);
  que.push_back(root), father[root] = 0, depth[root] = 0;
  for (int idx = 0; idx < ((int)(que).size()); ++idx) {
    int u = que[idx];
    for (int v : edges[u])
      if (father[u] != v)
        que.push_back(v), child[father[v] = u].push_back(v),
            depth[v] = depth[u] + 1;
  }
  for (int i = n - 1, u; i >= 0; --i) {
    nearest3[u = que[i]] = 0;
    for (int v : child[u])
      if (((int)(child[v]).size()) == 2)
        nearest3[u] = v;
      else if (nearest3[v])
        nearest3[u] = nearest3[v];
    size[father[u]] += ++size[u];
  }
  size[0] = 0;
}
int work2(int, int);
int work1(int u) {
  static struct INIT {
    INIT() { memset(f, 255, sizeof(f)); }
  } _INIT;
  if (u == 0) return 0;
  if (f[u] != -1) return f[u];
  f[u] = 0;
  if (((int)(child[u]).size()) == 1) {
    if (!nearest3[u]) return f[u] = size[u] / 2;
    int w = nearest3[u];
    if (depth[w] > depth[u] + 1) f[u] = add(f[u], work1(child[child[u][0]][0]));
    for (int t = 0; t < 2; ++t) {
      int c = child[w][t], space = depth[w] - depth[u] - 1;
      if (nearest3[c] || ((int)(child[c]).size()) > 1) continue;
      if (size[c] == space) f[u] = add(f[u], work1(child[w][t ^ 1]));
    }
    for (int t = 0; t < 2; ++t) {
      int c = child[w][t], c_ = child[w][t ^ 1],
          space = depth[w] - depth[u] + 1;
      if (((int)(child[c]).size()) == 1) {
        if (nearest3[c] || ((int)(child[c]).size()) > 1) continue;
        if (size[c] == space) f[u] = add(f[u], work1(c_));
      } else if (((int)(child[c]).size()) == 2) {
        for (int t = 0; t < 2; ++t) {
          int d = child[c][t], d_ = child[c][t ^ 1];
          if (((int)(child[d]).size()) > 1 || nearest3[d]) continue;
          if (size[d] == space - 1) f[u] = add(f[u], work2(c_, d_));
        }
      }
    }
  } else {
    for (int t = 0; t < 2; ++t) {
      int c = child[u][t], c_ = child[u][t ^ 1];
      if (!((int)(child[c]).size()))
        f[u] = add(f[u], work1(c_));
      else if (((int)(child[c]).size()) == 1)
        f[u] = add(f[u], work2(c_, child[c][0]));
    }
  }
  return f[u];
}
int work2(int a, int b) {
  if (!b) return work1(a);
  if (!a) return work1(b);
  int sa = ((int)(child[a]).size()), sb = ((int)(child[b]).size());
  if (sa == 2 || sb == 2) return 0;
  if (sa == 1 && sb == 1) return work2(child[a][0], child[b][0]);
  if (!sa && !sb) return 1;
  return ((int)(child[a]).size()) == 1 ? work1(child[a][0])
                                       : work1(child[b][0]);
}
void solve() {
  if (n == 1) {
    puts("2");
    return;
  }
  n <<= 1;
  int root = 1;
  for (int i = 1; i <= n; ++i)
    if (((int)(edges[i]).size()) > ((int)(edges[root]).size())) root = i;
  if (((int)(edges[root]).size()) > 3)
    puts("0");
  else if (((int)(edges[root]).size()) == 2)
    printf("%d\n", add(sub(mul(n >> 1, n), n), 4));
  else {
    bfs(root);
    vector<int> &son = child[root];
    sort(son.begin(), son.end());
    int ans = 0;
    do {
      if (((int)(child[son[2]]).size()) & 1) {
        int c = child[son[2]][0];
        for (int t = 0; t < 2; ++t) {
          if ((size[c] + size[son[t]]) & 1) continue;
          ans = add(ans, mul(work2(son[t], c), work1(son[t ^ 1])));
        }
      } else {
        for (int t = 0; t < 2; ++t) {
          int c = ((int)(child[son[2]]).size()) ? child[son[2]][t] : 0,
              c_ = ((int)(child[son[2]]).size()) ? child[son[2]][t ^ 1] : 0;
          if ((size[son[0]] + size[c]) & 1) continue;
          ans = add(ans, mul(work2(son[0], c), work2(son[1], c_)));
          if (!((int)(child[son[2]]).size())) break;
        }
      }
      if (debug) printf("%d %d\n", ans, ((int)(child[son[2]]).size()));
    } while (next_permutation(son.begin(), son.end()));
    printf("%d\n", mul(ans, 2));
    if (debug) {
      puts("YES");
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0, u, v; i < 2 * n - 1; ++i) {
    scanf("%d%d", &u, &v);
    edges[u].push_back(v), edges[v].push_back(u);
  }
  solve();
  return 0;
}
