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  
    
#include <bits/stdc++.h>
using namespace std;
const int INF = 1E9 + 7;
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
const long long mod = 1000000007;
int n, idx = 0;
vector<int> t[200005];
int kto_nr[200005], nr[200005], path_len[200005];
long long dp[200005];
vector<int> sons[200005];
int get_next(int act, int ile) { return kto_nr[nr[act] + ile]; }
int is_path(int a) {
  if (path_len[a] == -1) return 0;
  if (((int)(sons[get_next(a, path_len[a])]).size()) != 0) return 0;
  return path_len[a] + 1;
}
long long policz1(int a, int b) {
  if (0) cerr << "POLICZ1 " << a << " " << b << endl;
  int lena, lenb;
  lena = path_len[a];
  lenb = path_len[b];
  if (lena == -1 || lenb == -1) return 0;
  if (lena == lenb) {
    if (is_path(a) && is_path(b)) return 1;
    if (is_path(b)) {
      return dp[get_next(a, lena + 1)];
    } else if (is_path(a))
      return dp[get_next(b, lenb + 1)];
    return 0;
  }
  if (lena < lenb) {
    if (!is_path(a)) return 0;
    if (0) cout << "TAK " << endl;
    return dp[get_next(b, lena + 1)];
  } else {
    if (!is_path(b)) return 0;
    return dp[get_next(a, lenb + 1)];
  }
}
long long policz2(int a, int b) {
  if (0) cout << "POLICZ2 " << a << " " << b << endl;
  if (path_len[a] == -1) return 0;
  if (path_len[a] == 0) {
    if (((int)(sons[a]).size()) == 0)
      return dp[b];
    else
      return 0;
  } else
    return policz1(get_next(a, 1), b);
}
long long policz3(int a, int b, int dop) {
  assert(dop > 0);
  long long sum = 0;
  if (((int)(sons[a]).size()) == 0) return 0;
  if (((int)(sons[a]).size()) == 1) {
    if (is_path(a) - 1 == dop) return dp[b];
  } else {
    int son1, son2;
    son1 = sons[a][0];
    son2 = sons[a][1];
    if (is_path(son1) == dop) sum += policz1(son2, b);
    if (is_path(son2) == dop) sum += policz1(b, son1);
  }
  return sum % mod;
}
long long policz4(int a, int b, int dop) {
  if (dop < 0) return 0;
  int z = is_path(a);
  if (!z) return 0;
  if (z - 1 != dop) return 0;
  return dp[b];
}
void dfs(int act, int papa) {
  if (0) cerr << "DFS " << act << " " << papa << endl;
  nr[act] = ++idx;
  {
    if (0)
      cerr << "nr[act]"
           << " = " << nr[act] << endl;
  };
  kto_nr[idx] = act;
  for (__typeof((t[act]).begin()) it = ((t[act]).begin()); it != (t[act]).end();
       ++it) {
    if (*it == papa) continue;
    sons[act].push_back(*it);
    dfs(*it, act);
  }
  if (0) cerr << "SONS " << act << endl;
  {
    if (0) {
      cerr << "sons[act]"
           << " = ";
      for (__typeof(((sons[act])).begin()) it = (((sons[act])).begin());
           it != ((sons[act])).end(); ++it)
        cerr << *it << ", ";
      cout << endl;
    }
  };
  path_len[act] = -1;
  if (((int)(sons[act]).size()) == 1) {
    path_len[act] = path_len[sons[act][0]] + 1;
  } else if (((int)(sons[act]).size()) == 0)
    path_len[act] = 0;
  if (0) cerr << "PATH_LEN " << act << " " << path_len[act] << endl;
  if (((int)(sons[act]).size()) == 1) {
    int son = sons[act][0];
    if (path_len[son] != -1) {
      if (path_len[son] == 0) {
        if (is_path(son))
          dp[act] += 1;
        else
          dp[act] += dp[get_next(son, 1)];
      } else {
        dp[act] += dp[get_next(son, 1)];
      }
    }
    int l = is_path(son);
    if (l) {
      l--;
      if (l >= 2 && l % 2 == 0) dp[act]++;
    } else {
      int z = get_next(son, path_len[son] + 1);
      {
        if (0)
          cerr << "z"
               << " = " << z << endl;
      };
      int dop = path_len[son] + 2;
      {
        if (0)
          cerr << "dop"
               << " = " << dop << endl;
      };
      long long x, y;
      x = policz3(sons[z][0], sons[z][1], dop);
      y = policz3(sons[z][1], sons[z][0], dop);
      {
        if (0)
          cerr << "sons[z][0]"
               << " = " << sons[z][0] << endl;
      };
      {
        if (0)
          cerr << "x"
               << " = " << x << endl;
      };
      {
        if (0)
          cerr << "y"
               << " = " << y << endl;
      };
      dp[act] += x + y;
      x = policz4(sons[z][0], sons[z][1], dop - 2);
      y = policz4(sons[z][1], sons[z][0], dop - 2);
      if (0) cout << "Z!!!!!!!!!!!!!!! " << x + y << endl;
      {
        if (0)
          cerr << "x"
               << " = " << x << endl;
      };
      {
        if (0)
          cerr << "y"
               << " = " << y << endl;
      };
      dp[act] += x + y;
    }
  } else if (((int)(sons[act]).size()) == 2) {
    dp[act] += policz2(sons[act][0], sons[act][1]);
    dp[act] += policz2(sons[act][1], sons[act][0]);
  } else {
    dp[act] = 0;
  }
  dp[act] %= mod;
  if (0) cerr << "________________DP " << act << " " << dp[act] << endl;
}
bool done[200005];
int sum = 0;
bool neigh(int a, int b) {
  int l = n / 2;
  if (a > b) swap(a, b);
  if (b == a + 1) {
    if (a == l) return 0;
    return 1;
  }
  if (a + l == b) return 1;
  return 0;
}
int gdzie[200005];
int suma = 0;
bool moge(int act, int pos) {
  for (__typeof((t[act]).begin()) it = ((t[act]).begin()); it != (t[act]).end();
       ++it) {
    if (nr[*it] < nr[act] && !neigh(pos, gdzie[*it])) return 0;
  }
  return 1;
}
vector<int> G[200005];
int brut2(int kto) {
  if (kto == n + 1) {
    ++suma;
    return 0;
  }
  int act = kto_nr[kto];
  for (int i = (1); i <= (n); ++i)
    if (!done[i]) {
      if (moge(act, i)) {
        gdzie[act] = i;
        done[i] = 1;
        brut2(kto + 1);
        done[i] = 0;
      }
    }
}
int brut() {
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (n); ++j)
      if (neigh(i, j)) G[i].push_back(j);
  suma = 0;
  brut2(1);
  return suma;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  n *= 2;
  for (int i = (1); i <= (n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  int kto3 = -1;
  int kto1 = -1;
  for (int i = (1); i <= (n); ++i) {
    if (((int)(t[i]).size()) > 3) {
      cout << 0 << endl;
      return 0;
    }
    if (((int)(t[i]).size()) == 3) {
      kto3 = i;
    }
    if (((int)(t[i]).size()) == 1) kto1 = i;
  }
  int root = kto3;
  if (root == -1) root = kto1;
  dfs(root, -1);
  long long result = 0;
  if (((int)(sons[root]).size()) == 3) {
    if (0) cerr << "TRZY " << root << endl;
    vector<int>& so = sons[root];
    sort((so).begin(), (so).end());
    do {
      int a, b, c;
      a = so[0];
      b = so[1];
      c = so[2];
      long long res = 0;
      if (((int)(sons[b]).size()) == 0) {
        if (0) cout << "T " << dp[a] << " " << dp[c] << endl;
        res += dp[a] * dp[c];
      } else if (((int)(sons[b]).size()) == 1) {
        if (0) cout << "POLICZ " << policz1(sons[b][0], c) << endl;
        res += dp[a] * policz1(sons[b][0], c);
        {
          if (0)
            cerr << "res"
                 << " = " << res << endl;
        };
        res += dp[c] * policz1(sons[b][0], a);
        {
          if (0)
            cerr << "res"
                 << " = " << res << endl;
        };
      } else if (((int)(sons[b]).size()) == 2) {
        res += policz1(sons[b][0], a) * policz1(sons[b][1], c);
        {
          if (0)
            cerr << "res"
                 << " = " << res << endl;
        };
        res += policz1(sons[b][1], a) * policz1(sons[b][0], c);
        {
          if (0)
            cerr << "res"
                 << " = " << res << endl;
        };
      }
      res %= mod;
      result += res;
      if (0) cerr << "LICZ " << a << " " << b << " " << c << " " << res << endl;
    } while (next_permutation((so).begin(), (so).end()));
    result %= mod;
    result *= 2;
  } else {
    if (0) cerr << "PATH " << endl;
    result = 2 * dp[root];
    if (n != 2) result += 2 * dp[root];
    long long sum = 0;
    if (n >= 3) {
      for (int i = (4); i <= (n - 2); ++i) {
        sum += dp[get_next(root, i)];
        sum %= mod;
      }
    }
    result += 4 * sum;
  }
  result %= mod;
  cout << result << endl;
  return 0;
}
