#include <bits/stdc++.h>

using namespace std;

typedef long long ll;


int P = 1e9 + 7;
vector<ll> fac;

void factorial(){
    fac[0] = 1;
    for(int i = 1 ; i < fac.size(); ++i){
        fac[i] = fac[i-1] * i;
        fac[i] %= P;
    }
    return;
}

ll power(ll base, ll exp){
    ll ret = 1;
    while(exp > 0){
        if(exp % 2 == 0){
            base *= base;
            base %= P;
            exp /= 2;
        }
        else{
            ret *= base;
            ret %= P;
            exp -= 1;
        }
    }
    return ret;
}

int countSubtree(int here, vector<vector<int>>& g, vector<int>& subtree, unordered_set<int>& v){
    v.insert(here);
    int ret = 1;
    for(int i = 0 ; i < g[here].size(); ++i){
        int there = g[here][i];
        if(v.count(there) == 0){
            ret += countSubtree(there, g, subtree, v);
        }
    }
    subtree[here] = ret - 1;
    return ret;
}

ll mul(ll a, ll b){
    return (a * b) % P;
}

ll inv(ll a){
    return power(a,P-2);
}

void startFromRoot(int here, vector<vector<int>>& g, vector<int>& subtree, unordered_set<int>& v, vector<int>& dp){
    v.insert(here);
    ll ret = 1;
    ret = mul(ret, fac[subtree[here]]);
    for(int i = 0 ; i < g[here].size(); ++i){
        int there = g[here][i];
        if(v.count(there) == 0){
            startFromRoot(there, g, subtree, v, dp);
            ret = mul(ret, inv(fac[subtree[there]+1]));
            ret = mul(ret, dp[there]);
        }
    }
    dp[here] = ret;
    return;
}

void reroot(int here, vector<vector<int>>& g, vector<int>& subtree, unordered_set<int>& v, vector<int>& dp, vector<int>& ret){
    v.insert(here);
    for(int i = 0 ; i < g[here].size(); ++i){
        int there = g[here][i];
        int dh = dp[here];
        int dt = dp[there];
        int sh = subtree[here];
        int st = subtree[there];
        if(v.count(there) == 0){
            dp[here] = mul(dp[here], inv(fac[subtree[here]])); 
            dp[here] = mul(dp[here], fac[subtree[here] - subtree[there] - 1]);
            dp[here] = mul(dp[here], inv(dp[there]));
            dp[here] = mul(dp[here], fac[subtree[there]+1]);
            int sub = subtree[there];
            subtree[there] = subtree[here];
            subtree[here] -= (sub+1);
            dp[there] = mul(dp[there], dp[here]);
            dp[there] = mul(dp[there], fac[subtree[there]]);
            dp[there] = mul(dp[there], inv(fac[sub]));
            dp[there] = mul(dp[there], inv(fac[subtree[here]+1]));
            ret[there] = dp[there];
            reroot(there, g, subtree, v, dp, ret);
        }
        dp[here] = dh;
        dp[there] = dt;
        subtree[here] = sh;
        subtree[there] = st;
    }
    return;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N;
    cin >> N;
    vector<vector<int>> g(N+1);
    fac.resize(N+1);
    factorial();
    for(int i = 0 ; i < N-1 ; ++i){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> subtree(N+1);
    unordered_set<int> v(N+1);
    vector<int> dp(N+1);
    vector<int> ret(N+1);
    countSubtree(1, g, subtree, v);
    v.clear();
    startFromRoot(1, g, subtree, v, dp);
    ret[1] = dp[1];
    v.clear();
    reroot(1, g, subtree, v, dp, ret);
    for(int i = 1; i < N+1; ++i){
        cout << ret[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 25716