#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60
ll mod = 1e9 + 7;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
int N;

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void dfs1(int from, vector<ll>& dp1, vector<vector<int> >& edges, vector<ll>& t, vector<bool> visited) {
    visited[from] = true;

    t[from] = 1;
    for(int next: edges[from]) {
        if(visited[next]) continue;
        dfs1(next, dp1, edges, t, visited);
        t[from] += t[next];
        dp1[from] *= dp1[next];
        dp1[from] %= mod;
        dp1[from] = (dp1[from] * COM(t[from] - 1, t[next])) % mod;
    }
    return;
}

void dfs2(int from, int prev, ll res, vector<ll>& dp1, vector<ll>& dp2, vector<vector<int> >& edges, vector<ll>& t) {
    ll mul = (res * COM(N-1, t[from]-1)) % mod;
    dp2[from] = (mul * dp1[from]) % mod;
    for(int next: edges[from]) {
        if(next == prev) continue;
        ll next_res = divll(dp2[from], (dp1[next] * COM(N-1, t[next])) % mod);
        dfs2(next, from, next_res, dp1, dp2, edges, t);
    }
}

int main() {
    COMinit();
    
    cin >> N;
    vector< vector<int> > edges(N, vector<int>());
    REP(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<ll> dp1(N, 1), dp2(N, 1), t(N);
    vector<bool> visited1(N, false);
    dfs1(0, dp1, edges, t, visited1);

    dp2[0] = dp1[0];
    for(int next: edges[0]) {
        ll div = dp1[next] * COM(N-1, t[next]) % mod;
        ll res = divll(dp1[0], div);
        dfs2(next, 0, res, dp1, dp2, edges, t);
    }

    REP(i, N)
        cout << dp2[i] << endl;

    return 0;
}

Measured memory_bytes: 330112