#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; void mod_inverse(int n, vector& inv, int mod) { inv.assign(n+1, -1); inv[1] = 1; for(int i=2; i<=n; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod; } class FactorialCalculation { private: const int mod; vector factorial; vector invFactorial; public: FactorialCalculation(int n, int mod) : mod(mod) { factorial.resize(n+1, 1); invFactorial.resize(n+1, 1); vector inv; mod_inverse(n, inv, mod); for(int i=1; i<=n; ++i){ factorial[i] = factorial[i-1] * i % mod; invFactorial[i] = invFactorial[i-1] * inv[i] % mod; } } long long getFactorial(int n){ return factorial[n]; } long long getInvFactorial(int n){ return invFactorial[n]; } long long getPermutation(int n, int r){ if(n < r) return 0; return factorial[n] * invFactorial[n-r] % mod; } long long getCombination(int n, int r){ if(n < r) return 0; return getPermutation(n, r) * invFactorial[r] % mod; } long long getHomogeneous(int n, int r){ return getCombination(n+r-1, r); } }; void dfs(const vector > edges, int curr, int prev, int d, vector& depth) { depth[curr] = d; for(int next : edges[curr]){ if(next != prev) dfs(edges, next, curr, d+1, depth); } } const int MOD = 1000000007; int main() { int n; cin >> n; vector > edges(n); for(int i=0; i> u >> v; -- u; -- v; edges[u].push_back(v); edges[v].push_back(u); } vector depth(n); dfs(edges, 0, -1, 0, depth); FactorialCalculation fc(n, MOD); long long ans = 0; for(int i=0; i