#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>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
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> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


// 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;
}



VV G;

struct ReRooting {
  // edit area start
  struct DP {
    ll dp;
    int size;
    DP(ll dp=1, int size=0) : dp(dp), size(size) {}
  };
  DP f_merge(DP a, DP b) {
    return DP((a.dp * b.dp) % MOD * binom(a.size + b.size, a.size) % MOD, a.size + b.size);
  }
  DP f_trans(DP a) {
    return DP(a.dp, a.size+1);
  }
  // edit area end

  vector<vector<DP>> dp;
  vector<DP> ans;
  vector<int> p_idx;

  ReRooting(int N) : dp(N), ans(N), p_idx(N) {}

  DP dfs(int u, int p=-1) {
    int d = G[u].size();
    dp[u] = vector<DP>(d);
    DP res;
    rep(i, d) {
      int v = G[u][i];
      if (v == p) {
        p_idx[u] = i;
        continue;
      }
      dp[u][i] = dfs(v, u);
      res = f_merge(res, dp[u][i]);
    }
    return f_trans(res);
  }

  void dfs2(int u, int p=-1) {
    int d = G[u].size();
    vector<DP> res_l(d+1), res_r(d+1);
    rep(i, d)  res_l[i+1] = f_merge(res_l[i], dp[u][i]);
    drep(i, d) res_r[i] = f_merge(res_r[i+1], dp[u][i]);

    ans[u] = res_l[d];

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

  void build() {
    dfs(0);
    dfs2(0);
  }
};


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

  G = VV(N);
  for (int i = 0; i < N-1; ++i) {
    int u, v; cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  ReRooting reroot(N);
  reroot.build();

  rep(i, N) cout << reroot.ans[i].dp << endl;
  return 0;
}


Measured memory_bytes: 59636