#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define MOD 1000000007 long long comb(int n, int k, int mo); long long fast_pow(long long a, int n, int mo = 0); using namespace std; class Solution { public: void solve(std::istream& in, std::ostream& out) { int n; in >> n; int ar[n]; memset(ar, 0, sizeof(ar)); int a, b; for (int ctr1 = 1; ctr1 < n; ++ctr1) in >> a >> b, ++ar[a - 1], ++ar[b - 1]; int m = 0; for (int ctr1 = 1; ctr1 < n; ++ctr1) m += ar[ctr1] == 1; if (n == 1) { out << 1; return; } out << ((comb(n - 1, m, MOD) * comb(n - 1, m - 1, MOD) % MOD) * fast_pow(n - 1, MOD - 2, MOD)) % MOD; } }; void solve(std::istream& in, std::ostream& out) { out << std::setprecision(12); Solution solution; solution.solve(in, out); } // Powered by caide (code generator, tester, and library code inliner) #include #include int main() { ios_base::sync_with_stdio(false); cin.tie(0); istream& in = cin; ostream& out = cout; solve(in, out); return 0; } long long comb(int n, int k, int mo) { if (n - k < k) k = n - k; int inv[k + 1]; inv[0] = inv[1] = 1; for (long long ctr1 = 2; ctr1 <= k; ++ctr1) inv[ctr1] = inv[mo % ctr1] * (mo - mo / ctr1) % mo; long long rez = 1; for (int ctr1 = 2; ctr1 <= k; ++ctr1) rez = (rez * inv[ctr1]) % mo; for (int ctr1 = 0; ctr1 < k; ++ctr1) rez = (rez * (n - ctr1)) % mo; return rez; } long long fast_pow(long long a, int n, int mo) { if (n == 0) return 1; if (mo == 0) return ((n & 1) ? a : 1) * fast_pow(a * a, n >> 1, mo); return (((n & 1) ? a : 1) * fast_pow((a * a) % mo, n >> 1, mo)) % mo; }