//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1LL;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

ll mod_inv(ll x, ll mod) {
	return mod_pow(x, mod - 2, mod);
}
vector<ll> fac(1000001);  //n!(mod M)
int n;
vector<vector<ll>> v;
vector<ll> nodesum;
vector<ll> dp;
vector<ll> dp1;
//(全ての子の頂点の個数の階乗(全ての頂点の順列))/(それぞれの子の頂点数の階乗)*dp[子]
void dfs1(ll k,ll prev){
    dp[k]=1;
    ll node=0;
    rep(i,v[k].size()){
        if(v[k][i]==prev)continue;
        dfs1(v[k][i],k);
        dp[k]*=dp[v[k][i]];
        dp[k]%=MOD;
        node+=nodesum[v[k][i]];
        dp[k]*=mod_inv(fac[nodesum[v[k][i]]],MOD);
        dp[k]%=MOD;
    }
    dp[k]*=fac[node];
    nodesum[k]=node+1;
    dp[k]%=MOD;
}
void dfs2(ll k,ll prev){
    //cout<<k<<"\n";
    //debug(dp);
    //debug(nodesum);
    dp1[k]=1;
    ll node=0;
    rep(i,v[k].size()){
        dp1[k]*=dp[v[k][i]];
        dp1[k]%=MOD;
        node+=nodesum[v[k][i]];
        dp1[k]*=mod_inv(fac[nodesum[v[k][i]]],MOD);
        dp1[k]%=MOD;
    }
    dp1[k]*=fac[node];
    nodesum[k]=node+1;
    dp1[k]%=MOD;
    //debug(nodesum);
    dp[k]=dp1[k];
    dp[k]*=mod_inv(fac[nodesum[k]-1],MOD);
    rep(i,v[k].size()){
        if(v[k][i]==prev)continue;
        ll temp=dp[k];
        ll temp1=nodesum[k];
        nodesum[k]-=nodesum[v[k][i]];
        //dp[k]*=mod_inv(fac[temp1-1],MOD);
        dp[k]%=MOD;
        dp[k]*=fac[nodesum[k]-1];
        dp[k]%=MOD;
        dp[k]*=fac[nodesum[v[k][i]]];
        dp[k]%=MOD;
        dp[k]*=mod_inv(dp[v[k][i]],MOD);
        dp[k]%=MOD;
        dfs2(v[k][i],k);
        dp[k]=temp;
        nodesum[k]=temp1;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    v.resize(n);
    nodesum.resize(n);
    dp.resize(n);
    dp1.resize(n);
    fac[0] = 1;
    for (ll i = 0; i < 1000000; i++)
    {
        fac[i + 1] = fac[i] * (i + 1) % MOD;              // n!(mod M)
    }
    for (int i = 0; i < n-1; i++)
    {
        int temp,temp1;
        cin >> temp>>temp1;
        temp--;
        temp1--;
        v[temp].push_back(temp1);
        v[temp1].push_back(temp);
    }
    dfs1(0,-1);
    //debug(dp);
    dfs2(0,-1);
    //debug(dp1);
    rep(i,n){
        cout<<dp1[i]<<"\n";
    }
}


Measured memory_bytes: 27248