#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

template <typename T, typename U> T pow_fast(T x, U n) {
    T ret = (T)1;
    while(n) {
        if(n & (U)1) ret *= x;
        x *= x;
        n >>= 1;
    }
    return ret;
}

template <typename ModType, ModType MOD> struct ModInt {
    ModType val;
    ModInt() : val(0) {}
    ModInt(ModType x) : val(x % MOD) {
        if(val < 0) val += MOD;
    };
    operator ModType() const { return val; }
    ModInt &operator+=(const ModInt &m) {
        val += m.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    ModInt &operator-=(const ModInt &m) {
        val -= m.val;
        if(val < 0) val += MOD;
        return *this;
    }
    ModInt &operator*=(const ModInt &m) {
        (val *= m.val) %= MOD;
        return *this;
    }
    ModInt &operator/=(const ModInt &m) {
        *this *= m.inverse();
        return *this;
    }
    ModInt operator+(const ModInt &m) const { return ModInt(*this) += m; }
    ModInt operator-(const ModInt &m) const { return ModInt(*this) -= m; }
    ModInt operator*(const ModInt &m) const { return ModInt(*this) *= m; }
    ModInt operator/(const ModInt &m) const { return ModInt(*this) /= m; }
    ModInt inverse() const { return pow_fast(*this, MOD - 2); }
    ModInt pow(ModType n) const {return pow_fast(*this, n); }

    friend std::ostream &operator<<(std::ostream &os, const ModInt &rhs) {
        os << rhs.val;
        return os;
    }
    friend std::istream &operator>>(std::istream &is, ModInt &rhs) {
        ModType value;
        is >> value;
        rhs = ModInt(value);
        return is;
    }
};
template <class mint> struct Comb {
    vector<mint> fact;
    vector<mint> ifact;
    const int N;
    Comb(int n) : N(n + 1), fact(n + 1), ifact(n + 1) { makeFact(); }
    void makeFact() {
        fact[0] = ifact[0] = 1LL;
        for(int i = 1; i < N; i++) {
            fact[i] = fact[i - 1] * (mint)i;
            ifact[i] = fact[i].inverse();
        }
    }
    mint operator()(int n, int r) {
        if(n < 0 || r < 0 || r > n) return 0;
        if(r > n / 2) r = n - r;
        return fact[n] * ifact[n - r] * ifact[r];
    }
};
using mint = ModInt<ll, MOD>;
Comb<mint> comb(1e6);

vector<vi> es;
vi size_subgraph;
vector<mint> d;
vector<mint> ans;

int calc_size(int cur, int par) {
    auto& ret = size_subgraph[cur];
    ret = 1;
    for(auto&& to : es[cur]) if(to!=par) ret += calc_size(to, cur);
    return ret;
}

mint calc_d(int cur, int par) {
    auto& ret = d[cur];
    ret = mint(1);
    int cur_size = 0;
    for(auto&& to: es[cur]) if(to != par) {
        ret *= calc_d(to, cur);
        ret *= comb(cur_size+size_subgraph[to], cur_size);
        cur_size += size_subgraph[to];
    }
    return ret;
}

void calc_ans(int cur, int par) {
    if(par == -1) ans[cur] = d[cur];
    else {
        ans[cur] = d[cur];
        int cur_size = size_subgraph[cur];
        int n = es.size();
        mint par_d = ans[par] / d[cur] / comb(n-1, cur_size);
        int par_size = n - size_subgraph[cur];
        int sub_size = cur_size-1;
        ans[cur] *= par_d;
        ans[cur] *= comb(n-1, par_size);
    }
    for(auto&& to: es[cur]) if(to != par) calc_ans(to, cur);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    es.resize(n);
    size_subgraph.resize(n);
    d.resize(n);
    ans.resize(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        es[a].pb(b);
        es[b].pb(a);
    }
    calc_size(0, -1);
    calc_d(0, -1);
    calc_ans(0, -1);
    rep(i, n) {
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 33524