#include #define range(i, n) for(int (i) = 0; (i) < (n); (i)++) #define reversed_range(i, n) for(int (i) = (n) - 1; (i) >= 0; (i)--) using namespace std; template using vec = vector; using lint = long long; using ulint = unsigned long long; using pint = pair; template ostream& operator <<(ostream& os, vec v) { os << "["; for (int i = 0; i < v.size() - 1; i++) { os << v.at(i) << ", "; } return os << v.at(v.size() - 1) << "]"; } ulint powmod(ulint x, int e, lint MOD) { ulint result = 1; ulint current_num = x; int current_e = e; while (current_e) { if (current_e & 1) { result *= current_num; result %= MOD; } current_e >>= 1; current_num *= current_num; current_num %= MOD; } return result; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); const ulint MOD = 1e9 + 7; int N; cin >> N; vec> adj(N, vec()); for (int i = 0; i < N - 1; i++) { int u, v; cin >> u >> v; u -= 1; v -= 1; adj.at(u).emplace_back(v); adj.at(v).emplace_back(u); } vec factorial(N + 1, 0); factorial.at(0) = 1; for (ulint i = 1; i <= N; i++) { factorial.at(i) = factorial.at(i - 1) * i % MOD; } vec inv_num(N + 1, 0); for (ulint i = i; i <= N; i++) { inv_num.at(i) = powmod(i, MOD - 2, MOD); } vec depth(N, -1); deque nodes_to_traversed; nodes_to_traversed.emplace_back(0, 0); while (!nodes_to_traversed.empty()) { int node = nodes_to_traversed.front().first, dep = nodes_to_traversed.front().second; nodes_to_traversed.pop_front(); depth.at(node) = dep; for (auto neighbor : adj.at(node)) { if (depth.at(neighbor) == -1) nodes_to_traversed.emplace_back(neighbor, dep + 1); } } ulint result = 0; for (int node = 0; node < N; node++) { int dep = depth.at(node); result += inv_num.at(dep + 1); result %= MOD; } result *= factorial.at(N); result %= MOD; cout << result << "\n"; }