#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]=dwu(roz[v],roz[i])*dp[v]%mod*dp[i]%mod;
//cout<<i<<' '<<dwu(roz[v],roz[i])<<endl;
roz[v]+=roz[i];
}
}
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];
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGNvbnN0IE49MjAwMDAxLG1vZD0xZTkrNzsKbG9uZyBsb25nIG9kc1tOXSxzaWxbTl0sZHBbTl0sem07CmludCByb3pbTl07CmJvb2wgb2R3W05dOwp2ZWN0b3I8aW50PmdbTl07Cgpsb25nIGxvbmcgZHd1KGludCBuLCBpbnQgayl7CiAgICBpZihrPm4pIHN3YXAobixrKTsKICAgIC8vY291dDw8c2lsW24rMV08PCcgJzw8b2RzW2tdPDwnICc8PG9kc1tuLWsrMV08PGVuZGw7CiAgICByZXR1cm4gKChsb25nIGxvbmcpc2lsW24rMV0qb2RzW2tdJW1vZCpvZHNbbi1rKzFdKSVtb2Q7Cn0KCnZvaWQgZGZzKGludCB2KXsKICAgIG9kd1t2XT0xOwogICAgZHBbdl09MTsKICAgIGZvcihpbnQgaTpnW3ZdKXsKICAgICAgICBpZihvZHdbaV09PTApewogICAgICAgICAgICBkZnMoaSk7CiAgICAgICAgICAgIGRwW3ZdPWR3dShyb3pbdl0scm96W2ldKSpkcFt2XSVtb2QqZHBbaV0lbW9kOwogICAgICAgICAgICAvL2NvdXQ8PGk8PCcgJzw8ZHd1KHJvelt2XSxyb3pbaV0pPDxlbmRsOwogICAgICAgICAgICByb3pbdl0rPXJveltpXTsKICAgICAgICB9CgogICAgfQogICAgcm96W3ZdKys7CiAgICAvL2NvdXQ8PHY8PCcgJzw8ZHBbdl08PGVuZGw7Owp9Cgpsb25nIGxvbmcgcG90KGludCBiYXNlLGludCB3eWspewoJLy9jb3V0PDxiYXNlPDwnICc8PHd5azw8ZW5kbDsKICAgIGlmKHd5az09MCkgcmV0dXJuIDE7CiAgICBpZih3eWs9PTEpIHJldHVybiBiYXNlOwogICAgaWYod3lrJTI9PTApewogICAgICAgIHptPXBvdChiYXNlLHd5ay8yKTsKICAgICAgICAvL2NvdXQ8PCh6bSp6bSklbW9kPDxlbmRsOwogICAgICAgIHJldHVybiAoem0qem0pJW1vZDsKICAgIH0KICAgIHptPShwb3QoYmFzZSx3eWstMSkqYmFzZSklbW9kOwogICAgLy9jb3V0PDx6bTw8ZW5kbDsKICAgIHJldHVybiB6bTsKfQoKaW50IG1haW4oKXsKCWlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CgljaW4udGllKDApOwogICAgaW50IG4sYSxiOwogICAgY2luPj5uOwogICAgc2lsWzBdPTE7CiAgICBvZHNbMF09MTsKICAgIC8vY291dDw8cG90KDIsbW9kLTIpOwogICAgZm9yKGludCBpPTE7aTw9bjtpKyspIHtzaWxbaV09KChsb25nIGxvbmcpc2lsW2ktMV0qaSklbW9kOyBvZHNbaV09cG90KHNpbFtpXSxtb2QtMik7fQogICAgZm9yKGludCBpPTE7aTxuO2krKyl7CiAgICAgICAgY2luPj5hPj5iOwogICAgICAgIGdbYV0ucHVzaF9iYWNrKGIpOwogICAgICAgIGdbYl0ucHVzaF9iYWNrKGEpOwogICAgfQogICAgZGZzKDEpOwogICAgY291dDw8ZHBbMV07Cn0K