#include #define show(x) std::cerr << #x << " = " << x << std::endl using ll = long long; constexpr ll MOD = 1000000007LL; template class ModCombination { public: ModCombination(const std::size_t n) : fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1) { for (ll i = 2; i <= (ll)n; i++) { fact[i] = (fact[i - 1] * i) % mod, inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod, inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod; } } ll factorial(const std::size_t n) const { return fact[n]; } ll inverse(const std::size_t n) const { return inv[n]; } ll inverseFactorial(const std::size_t n) const { return inv_fact[n]; } ll permutation(const std::size_t n, const std::size_t k) const { return (fact[n] * inv_fact[n - k]) % mod; } ll combination(const std::size_t n, const std::size_t k) const { return (((fact[n] * inv_fact[k]) % mod) * inv_fact[n - k]) % mod; } private: std::vector fact, inv, inv_fact; }; int main() { int N; std::cin >> N; std::vector> g(N); for (int i = 0, u, v; i < N - 1; i++) { std::cin >> u >> v, u--, v--; g[u].push_back(v), g[v].push_back(u); } if (N <= 2) { return std::cout << 1 << std::endl, 0; } std::vector LOG; auto dfs = [&](auto&& self, const int s, const int prev) -> void { for (const int to : g[s]) { if (to == prev) { continue; } LOG.push_back(1); self(self, to, s); LOG.push_back(-1); } }; dfs(dfs, 0, -1); int d = 0; for (int i = 1; i < 2 * (N - 1); i++) { if (LOG[i - 1] != LOG[i]) { d++; } } (d -= 1) /= 2; N -= 2; ModCombination<> mod(2 * N); std::vector cat(2 * N + 1, 0); for (int i = 0; i <= N; i++) { cat[2 * i] = mod.combination(2 * i, i) * mod.inverse(i + 1) % MOD; } std::vector coeff(N + 1, 0); for (int i = 0; i <= N; i += 2) { coeff[i] = mod.combination(N, i) * cat[i] % MOD; } ll ans = 0; for (int i = 0; i <= 2 * d; i += 2) { (ans += mod.combination(N - i, d - i / 2) * coeff[i] % MOD) %= MOD; } std::cout << ans << std::endl; return 0; }