#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n , sz[N] , dp[N];
int ans[N];
vector<int> v1[N];
vector<int> pref[N];
deque<int> suf[N];
deque<int> v2[N];
vector<int> g[N];
int fact[N] , inv[N];
int fp(int x , int y) {
    if(!y)
        return 1;
    int res = fp(x , y / 2);
    res = (1ll * res * res) % mod;
    if(y & 1)
        res = (1ll * res * x) % mod;
    return res;
}
void pre() {
    fact[0] = inv[0] = 1;
    for(int i = 1;i < N;i++) {
        fact[i] = (1ll * fact[i - 1] * i) % mod;
        inv[i] = fp(fact[i] , mod - 2);
    }
}
int ncr(int n , int r) {
    return (1ll * (1ll * fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}
void dfs(int node , int par) {
    dp[node] = 1;
    for(auto &i : g[node])
        if(i != par) {
            dfs(i , node);
            dp[node] = (1ll * dp[node] * dp[i]) % mod;
            dp[node] = (1ll * dp[node] * ncr(sz[node] + sz[i] , sz[i])) % mod;
            sz[node] += sz[i];
        }
    sz[node]++;
    int k = g[node].size();
    int a = 1 , b = 0;
    for(int i = 0;i < k;i++) {
        int u = g[node][i];
        if(u != par) {
            a = (1ll * a * dp[u]) % mod;
            a = (1ll * a * ncr(b + sz[u] , sz[u])) % mod;
            b += sz[u];
            pref[node].push_back(a);
            v1[node].push_back(b);
        } else {
            pref[node].push_back(a);
            v1[node].push_back(b);
        }
    }
    a = 1 , b = 0;
    for(int i = k - 1;i >= 0;i--) {
        int u = g[node][i];
        if(u != par) {
            a = (1ll * a * dp[u]) % mod;
            a = (1ll * a * ncr(b + sz[u] , sz[u])) % mod;
            b += sz[u];
            suf[node].push_front(a);
            v2[node].push_front(b);
        } else {
            suf[node].push_front(a);
            v2[node].push_front(b);
        }
    }
}
void solve(int node , int par) {
    ans[node] = dp[node];
    for(int i = 0;i < g[node].size();i++) {
        int u = g[node][i];
        if(u != par) {
            int dp1 = dp[node] , dp2 = dp[u];
            int sz1 = sz[node] , sz2 = sz[u];
            sz[node] = 0;
            dp[node] = max(1 , dp[par]);
            dp[node] = (1ll * dp[node] * ncr(sz[par] + sz[node] , sz[par])) % mod;
            sz[node] += sz[par];
            if(i) {
                dp[node] = (1ll * dp[node] * pref[node][i - 1]) % mod;
                dp[node] = (1ll * dp[node] * ncr(sz[node] + v1[node][i - 1] , sz[node])) % mod;
                sz[node] += v1[node][i - 1];
            }
            if(i < suf[node].size() - 1) {
                dp[node] = (1ll * dp[node] * suf[node][i + 1]) % mod;
                dp[node] = (1ll * dp[node] * ncr(sz[node] + v2[node][i + 1] , sz[node])) % mod;
                sz[node] += v2[node][i + 1];
            }
            sz[node]++ , sz[u]--;
            dp[u] = (1ll * dp[u] * dp[node]) % mod;
            dp[u] = (1ll * dp[u] * ncr(sz[node] + sz[u] , sz[u])) % mod;
            sz[u] += sz[node] + 1;
            solve(u , node);
            dp[node] = dp1 , dp[u] = dp2;
            sz[node] = sz1 , sz[u] = sz2;
        }
    }
}
int main() {
    abdelrahman010
    cin >> n;
    pre();
    for(int i = 1;i < n;i++) {
        int u , v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1 , 1);
    solve(1 , 0);
    for(int i = 1;i <= n;i++)
        cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 517920