#include using namespace std; const int M = int(1e9 + 7); signed main() { ios::sync_with_stdio(false); int N; cin >> N; vector deg(N); for (int i = 0; i + 1 < N; ++i) { int X, Y; cin >> X >> Y; --X, --Y; ++deg[X], ++deg[Y]; } int lcnt = count(deg.begin(), deg.end(), 1) - (deg[0] == 1); vector fac(N); for (int i = fac[0] = 1; i < N; ++i) fac[i] = 1LL * fac[i - 1] * i % M; auto int_pow = [](int x, int e) { int r = 1; for (int i = e; i; i /= 2) { if (i & 1) r = 1LL * r * x % M; x = 1LL * x * x % M; } return r; }; vector ifac(N); ifac[N - 1] = int_pow(fac[N - 1], M - 2); for (int i = N - 1; i; --i) ifac[i - 1] = 1LL * ifac[i] * i % M; vector inv(N); for (int i = 1; i < N; ++i) inv[i] = 1LL * ifac[i] * fac[i - 1] % M; int a = 1LL * fac[N - 1] * ifac[lcnt - 1] % M * ifac[N - lcnt] % M; int b = 1LL * fac[N - 2] * ifac[lcnt - 1] % M * ifac[N - lcnt - 1] % M; int ans = 1LL * a * b % M * inv[lcnt] % M; if (ans < 0) ans += M; cout << ans << endl; return 0; }