#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;
//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 10000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------

template<typename T>
struct treeDP{
  vvl G;
  T INIT, ZERO;
  vector<T> TMP_DATA, dat;
  function<T(T, T)> f;
  function<T(T)> g;
  treeDP(ll n, T init, T zero, function<T(T, T)> func, function<T(T)> func2):f(func), g(func2){
    G.resize(n+1, vector<ll>(0));
    dat.resize(n+1, zero);
    TMP_DATA.resize(n+1, zero);
    INIT = init, ZERO = zero;
  }

  inline void dfs(ll now, ll from){
    ll cnt = 0;
    for(int i=0;i<G[now].size();i++){
      if(G[now][i]==from) continue;
      dfs(G[now][i], now);
      TMP_DATA[now] = f(TMP_DATA[now], g(TMP_DATA[G[now][i]]));
      cnt++;
    }
    if(cnt==0) TMP_DATA[now] = INIT;
  }

  inline void dfs2(ll now, ll from, T rev){
    vector<T> left, right;
    for(int i=0;i<G[now].size();i++){
      ll to = G[now][i];
      if(to==from) continue;
      left.push_back(g(TMP_DATA[to]));
      ll s = left.size();
      if(s!=1) left[s-1] = f(left[s-1], left[s-2]);
    }
    for(int i=0;i<G[now].size();i++){
      ll to = G[now][G[now].size()-1-i];
      if(to==from) continue;
      right.push_back(g(TMP_DATA[to]));
      ll s = right.size();
      if(s!=1) right[s-1] = f(right[s-1], right[s-2]);
    }

    dat[now] = f((left.size()==0?ZERO:left[left.size()-1]), rev);

    ll cnt = 0;
    for(int i=0;i<G[now].size();i++){
      ll to = G[now][i];
      if(to==from) continue;
      T tmp = rev;
      if(cnt!=0) tmp = f(tmp, left[cnt-1]);
      if(cnt!=right.size()-1) tmp = f(tmp, right[right.size()-2-cnt]);
      dfs2(to, now, g(tmp));
      cnt++;
    }
  }

  void insert(ll a, ll b){ G[a].push_back(b);G[b].push_back(a); }

  void calc(){
    ll root = -1;
    for(int i=1;i<=G.size();i++) {
      if(G[i].size()==1) {
        root = i;
        break;
      }
    }
    dfs(root, -1);
    dfs2(root, -1, INIT);
  }
  T & operator [](int i){return dat[i];}
};

vll mg(vll a, vll b){
  if(a[0]==-1) return b;
  if(b[0]==-1) return a;
  vll c = a;
  c[0] = (comb(a[1]+b[1], a[1])*((a[0]*b[0])%P))%P;
  c[1] = a[1] + b[1];
  return c;
}
vll st(vll a){
  a[1]++;
  return a;
}

int main(int argc, char const *argv[]) {
  init();
  ll n, a, b;std::cin >> n;
  treeDP<vll> tdp(n, vll{1, 0}, vll{-1, -1}, mg, st);
  re(i, n-1){
    scanf("%lld %lld", &a, &b);
    tdp.insert(a, b);
  }
  tdp.calc();
  //for(int i=1;i<=n;i++) std::cout << tdp.TMP_DATA[i][0] << " "  << tdp.TMP_DATA[i][1] << '\n';
  for(int i=1;i<=n;i++) std::cout << tdp[i][0] << '\n';
  return 0;
}


Measured memory_bytes: 294632