#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> inline int Log2(T& x) {int k; for(k=0; (T(1)<<k)<=x; ++k); return k;} // number of binary digits


// initialization
const int F_MAX = int(1e6)+10;
ll fac[F_MAX], finv[F_MAX], inv[F_MAX];
void binom_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < F_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;
  }
}

// binom mod MOD
ll binom(int n, int k) {
  if (k < 0 || n < k) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}


// DP
template<typename T>
struct rerooting {
  struct edge {
    int v; T dp_sub;
    edge(int v) : v(v) {}
  };

  using Edges = vector<edge>;
  using Graph = vector<Edges>;
  Graph G;
  const T ident;
  vector<T> dp;

  using Fm = function<T(T, T)>;
  using Ft = function<T(T)>;
  const Fm f_merge;
  const Ft f_trans;

  rerooting(int N, const T &ident, const Fm fm, const Ft ft)
    : G(N), ident(ident), dp(N, ident), f_merge(fm), f_trans(ft) {}

  void add_edge(int u, int v) {
    G[u].push_back(edge(v));
    G[v].push_back(edge(u));
  }

  T dfs(int u, int p=-1) {
    T res = ident;
    int d = G[u].size();
    for (auto &e : G[u]) {
      if (e.v == p) continue;
      e.dp_sub = dfs(e.v, u);
      res = f_merge(res, e.dp_sub);
    }
    return f_trans(res);
  }

  void dfs2(int u, T par, int p=-1) {
    int d = G[u].size();
    rep(i, d) if (G[u][i].v == p) G[u][i].dp_sub = par;

    for (auto &e : G[u]) dp[u] = f_merge(dp[u], e.dp_sub);

    vector<T> res_l(d+1, ident), res_r(d+1, ident);
    rep(i, d)  res_l[i+1] = f_merge(res_l[i], G[u][i].dp_sub);
    drep(i, d) res_r[i] = f_merge(res_r[i+1], G[u][i].dp_sub);

    rep(i, d) {
      auto e = G[u][i];
      if (e.v == p) continue;
      dfs2(e.v, f_trans(f_merge(res_l[i], res_r[i+1])), u);
    }
  }

  vector<T> build() {
    dfs(0);
    dfs2(0, ident);
    return dp;
  }
};


int main() {
  binom_init();
  int N; cin >> N;

  using Tdp = pair<ll, int>;

  auto f_merge = [&] (Tdp a, Tdp b) {
    return Tdp((a.fst * b.fst) % MOD * binom(a.snd + b.snd, a.snd) % MOD, a.snd + b.snd);
  };
  auto f_trans = [&] (Tdp a) {
    return Tdp(a.fst, a.snd+1);
  };

  rerooting<Tdp> G(N, Tdp(1, 0), f_merge, f_trans);

  for (int i = 0; i < N-1; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G.add_edge(a, b);
  }
  
  auto dp = G.build();
  rep(i, N) cout << dp[i].fst << endl;
  return 0;
}


Measured memory_bytes: 50688