#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = (ll)1000000007 * 1000000007; typedef pair P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef long double ld; typedef complex Point; const ld eps = 1e-11; const ld pi = acos(-1.0); typedef pair LP; typedef pair LDP; typedef unsigned long long ul; //x,yがax+by=gcd(a,b)の解になる ll extgcd(ll a, ll b, ll& x, ll& y) { ll d = a; if (b != 0) { d = extgcd(b, a%b, y, x); y -= (a / b)*x; } else { x = 1; y = 0; } return d; } //aのmod mでの逆元を求める ll mod_inverse(ll a, ll m) { ll x, y; extgcd(a, m, x, y); return (m + x % m) % m; } const int N_MAX = 1 << 18; ll p[N_MAX]; void init() { p[0] = 1; rep1(i, N_MAX - 1) { p[i] = p[i - 1] * i%mod; } } //xCyを求める ll comb(ll x, ll y, ll m) { if (x < y)return 0; ll res = p[x]; (res *= mod_inverse(p[y], m)) %= mod; (res *= mod_inverse(p[x - y], m)) %= mod; return res; } vector G[1 << 17]; bool used[1 << 17]; int dfs(int id) { used[id] = true; if (G[id].size() == 1&&used[G[id][0]])return 1; int res = 0; rep(j, G[id].size()) { int to = G[id][j]; if (used[to])continue; res += dfs(to); } return res; } int main() { int n; cin >> n; init(); if (n == 1) { cout << 1 << endl; return 0; } rep(i, n-1) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } int t = dfs(0); //cout << t << endl; ll out = comb(n - 1, t - 1, mod)*comb(n - 2, t - 1, mod) % mod*mod_inverse(t, mod) % mod; cout << out << endl; return 0; }