#include <bits/stdc++.h>

#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;


ll factorial(ll n,ll mod=mod){
  static ll dp[400000];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1,mod))%mod;
}

ll powl(ll x,ll r,ll mod=mod){
  ll ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

ll inverse(ll x,ll mod=mod){
  return powl(x,mod-2,mod);
}


ll n;
graph g;
v2 child_size_mem;
v2 pattern_num_mem;
v1 ans;


// child_size, pattern_num
tuple<ll,ll> gather_dfs(ll from, ll to){

    for(auto y : g[to]){
        if(y.first == from){
            continue;
        }
        ll a,b;
        tie(a,b) = gather_dfs(to, y.first);
        child_size_mem[to].push_back(a);
        pattern_num_mem[to].push_back(b);
    }
    ll cs = accumulate(child_size_mem[to].begin(),child_size_mem[to].end(),0ll);
    ll pn = 1;
    for(ll y : pattern_num_mem[to]){
        pn *= y;
        pn %= mod;
    }
    pn *= factorial(cs);
    pn %= mod;
    for(ll y : child_size_mem[to]){
        pn *= inverse(factorial(y), mod);
        pn %= mod;
    }
    auto ret = make_tuple(cs+1, pn);

    // debug(child_size_mem[to]);
    // debug(pattern_num_mem[to]);
    // debug(cs+1);
    // debug(pn);
    return ret;


}

//                                  child_size, pattern_num
void scatter_dfs(ll from, ll to, tuple<ll,ll> content){
    ll i = 0;
    ll pn_inv = 1;
    ll pn_all = 1;
    ll content_cs,content_pn;
    tie(content_cs, content_pn) = content;
    // debug(to);
    // debug(content_cs);
    // debug(content_pn);
    // debug(child_size_mem[to]);
    // debug(pattern_num_mem[to]);
    pn_inv *= inverse(factorial(content_cs));
    pn_inv %= mod;
    for(ll p : child_size_mem[to]){
        pn_inv *= inverse(factorial(p));
        pn_inv %= mod;
    }
    pn_all *= content_pn;
    pn_all %= mod;
    for(ll p : pattern_num_mem[to]){
        pn_all *= p;
        pn_all %= mod;
    }
    pn_all *= pn_inv;
    pn_all %= mod;
    ll pn_ans = pn_all;
    pn_ans *= factorial(n-1);
    pn_ans %= mod;
    ans[to] = pn_ans;
    for(auto y : g[to]){
        if(y.first == from){
            continue;
        }
        ll cs = n-child_size_mem[to][i]-1;
        ll pn_all_ = pn_all;
        pn_all_ *= factorial(cs);
        pn_all_ %= mod;
        pn_all_ *= factorial(child_size_mem[to][i]);
        pn_all_ %= mod;
        pn_all_ *= inverse(pattern_num_mem[to][i]);
        pn_all_ %= mod;
        scatter_dfs(to, y.first, make_tuple(cs+1, pn_all_));
        i++;
    }
}

int main(){
    cin >> n;
    for(ll i = 0;i < n-1;i++){
        ll a,b;
        cin >> a >> b;
        g[a][b] = g[b][a] = 0;
    }
    child_size_mem = v2(n+1);
    pattern_num_mem = v2(n+1);
    ans = v1(n+1);
    gather_dfs(0, 1);
    scatter_dfs(0, 1, make_tuple(0ll, 1ll));
    for(ll i = 1;i <= n;i++){
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 64768