#include<bits/stdc++.h>
using namespace std;
int const N=200001,mod=1e9+7;
long long ods[N],sil[N],dp[N],zm;
int roz[N];
bool odw[N];
vector<int>g[N];
long long dwu(int n, int k){
if(k>n) swap(n,k);
//cout<<sil[n+1]<<' '<<ods[k]<<' '<<ods[n-k+1]<<endl;
return ((long long)sil[n+1]*ods[k]%mod*ods[n-k+1])%mod;
}
void dfs(int v){
odw[v]=1;
dp[v]=1;
for(int i:g[v]){
if(odw[i]==0){
dfs(i);
dp[v]=dp[v]*dp[i]%mod*ods[roz[i]]%mod;
//dp[v]=dwu(roz[v],roz[i])*dp[v]%mod*dp[i]%mod;
//cout<<i<<' '<<dwu(roz[v],roz[i])<<endl;
roz[v]+=roz[i];
}
}
dp[v]=dp[v]*sil[roz[v]]%mod;
roz[v]++;
//cout<<v<<' '<<dp[v]<<endl;;
}
long long pot(int base,int wyk){
//cout<<base<<' '<<wyk<<endl;
if(wyk==0) return 1;
if(wyk==1) return base;
if(wyk%2==0){
zm=pot(base,wyk/2);
//cout<<(zm*zm)%mod<<endl;
return (zm*zm)%mod;
}
zm=(pot(base,wyk-1)*base)%mod;
//cout<<zm<<endl;
return zm;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,a,b;
cin>>n;
sil[0]=1;
ods[0]=1;
//cout<<pot(2,mod-2);
for(int i=1;i<=n;i++) {sil[i]=((long long)sil[i-1]*i)%mod; ods[i]=pot(sil[i],mod-2);}
for(int i=1;i<n;i++){
cin>>a>>b;
g[a].push_back(b);
g[b].push_back(a);
}
dfs(1);
cout<<dp[1];
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGNvbnN0IE49MjAwMDAxLG1vZD0xZTkrNzsKbG9uZyBsb25nIG9kc1tOXSxzaWxbTl0sZHBbTl0sem07CmludCByb3pbTl07CmJvb2wgb2R3W05dOwp2ZWN0b3I8aW50PmdbTl07Cgpsb25nIGxvbmcgZHd1KGludCBu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