#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
int mod_add(int A, int B) { return (A + B) % MOD; }
int mod_sub(int A, int B) { return (A + MOD - B) % MOD; }
int mod_mul(int A, int B) { return ((A % MOD) * (B % MOD)) % MOD; }
int mod_bipow(int X, int Y) {
    if (Y == 0) return 1;
    else if (Y == 1) return X % MOD;
    else if (Y % 2 == 0) {
        int Z = mod_bipow(X, (int)(Y / 2));
        return mod_mul(Z, Z);
    } else {
        int Z = mod_bipow(X, (int)(Y / 2));
        return mod_mul(mod_mul(Z, Z), X);
    }
}
int mod_inv(int X) { return mod_bipow(X, MOD - 2); }
int mod_div(int A, int B) { return mod_mul(A, mod_inv(B)); }

int ceil_div(int X, int Y) {
  return (X - 1) / Y + 1;
}

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

vi fact;
struct vertex {
  vector<int> adj = vi(0);
  int dp = 0;
  int p_dp = 1;
  int p_s = 1;
  int s = 1;
  void update_dp() {
    dp = mod_div(mod_mul(p_dp, fact[s - 1]), p_s);
  };
};
int n;
vector<vertex> v;

void dfs(int x, int p) {
  EACH(i, v[x].adj) {
    if (i == p) continue;
    dfs(i, x);
    v[x].p_dp = mod_mul(v[x].p_dp, v[i].dp);
    v[x].p_s = mod_mul(v[x].p_s, fact[v[i].s]);
    v[x].s += v[i].s;
  }
  v[x].update_dp();
}

void r_dfs(int x, int p) {
  EACH(i, v[x].adj) {
    if (i == p) continue;
    int p_dp_x = mod_div(v[x].p_dp, v[i].dp);
    int p_s_x = mod_div(v[x].p_s, fact[v[i].s]);
    int s_x = v[x].s - v[i].s;
    int dp_x = mod_div(mod_mul(p_dp_x, fact[s_x - 1]), p_s_x);
    v[i].p_dp = mod_mul(v[i].p_dp, dp_x);
    v[i].p_s = mod_mul(v[i].p_s, fact[s_x]);
    v[i].s += s_x;
    v[i].update_dp();
    r_dfs(i, x);
  }
}

void solve() {
  int ans = 0;

  cin >> n;
  v = vector<vertex>(n);
  fact = vi(n, 1);
  FOR(i, 1, n) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    v[a].adj.pb(b);
    v[b].adj.pb(a);
    fact[i] = mod_mul(fact[i - 1], i);
  }
  dfs(0, -1);
  r_dfs(0, -1);
  REP(i, n) {
    cout << v[i].dp << endl;
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 22512