/* -*- coding: utf-8 -*- * * 827.cc: No.827 総神童数 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int MOD = 1000000007; /* typedef */ typedef long long ll; typedef vector vi; typedef queue qi; /* global variables */ vi nbrs[MAX_N]; int prts[MAX_N], ds[MAX_N]; ll fs[MAX_N + 1]; /* subroutines */ ll powmod(ll a, int n) { // a^n % MOD ll pm = 1; while (n > 0) { if (n & 1) pm = (pm * a) % MOD; a = (a * a) % MOD; n >>= 1; } return pm; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 1; i < n; i++) { int a, b; scanf("%d%d", &a, &b); a--, b--; nbrs[a].push_back(b); nbrs[b].push_back(a); } prts[0] = -1, ds[0] = 0; qi q; q.push(0); while (! q.empty()) { int u = q.front(); q.pop(); int &up = prts[u], vd = ds[u] + 1; vi &nbru = nbrs[u]; for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) { int &v = *vit; if (v != up) { prts[v] = u; ds[v] = vd; q.push(v); } } } fs[0] = 1; for (int i = 1; i <= n; i++) fs[i] = fs[i - 1] * i % MOD; ll sum = 0; for (int i = 0; i < n; i++) sum = (sum + fs[n] * powmod((ll)ds[i] + 1, MOD - 2) % MOD) % MOD; printf("%lld\n", sum); return 0; }