#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <typename Data, typename T>
struct ReRooting {
    struct Node {
        int to, rev;
        Data data;
    };

    using F1 = function<T(T, T)>;
    using F2 = function<T(T, Data)>;

    vector<vector<Node>> g;
    vector<vector<T>> ldp, rdp;
    vector<int> lptr, rptr;
    const F1 f1;
    const F2 f2;
    const T ident;

    ReRooting(int n, const F1 &f1, const F2 &f2, const T &ident)
        : g(n), ldp(n), rdp(n), lptr(n), rptr(n), f1(f1), f2(f2), ident(ident) {
    }

    void add_edge(int u, int v, const Data &d) {
        g[u].emplace_back((Node){v, (int)g[v].size(), d});
        g[v].emplace_back((Node){u, (int)g[u].size() - 1, d});
    }

    void add_edge_bi(int u, int v, const Data &d, const Data &e) {
        g[u].emplace_back((Node){v, (int)g[v].size(), d});
        g[v].emplace_back((Node){u, (int)g[u].size() - 1, e});
    }

    T dfs(int now, int pre) {
        while (lptr[now] != pre && lptr[now] < g[now].size()) {
            auto &e = g[now][lptr[now]];
            ldp[now][lptr[now] + 1] =
                f1(ldp[now][lptr[now]], f2(dfs(e.to, e.rev), e.data));
            lptr[now]++;
        }

        while (rptr[now] != pre && rptr[now] >= 0) {
            auto &e = g[now][rptr[now]];
            rdp[now][rptr[now]] =
                f1(rdp[now][rptr[now] + 1], f2(dfs(e.to, e.rev), e.data));
            rptr[now]--;
        }

        if (pre < 0) return rdp[now][0];
        return f1(ldp[now][pre], rdp[now][pre + 1]);
    }

    vector<T> solve() {
        for (int i = 0; i < g.size(); i++) {
            ldp[i].assign(g[i].size() + 1, ident);
            rdp[i].assign(g[i].size() + 1, ident);
            lptr[i] = 0;
            rptr[i] = (int)g[i].size() - 1;
        }
        vector<T> ret;
        for (int i = 0; i < g.size(); i++) {
            ret.push_back(dfs(i, -1));
        }
        return ret;
    }
};
struct modint {
    ll x;
    modint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    ll value() const {
        return x;
    }
    modint operator-() const {
        return modint(-x);
    }
    modint &operator+=(const modint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint &operator-=(const modint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint &operator*=(const modint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    modint operator+(const modint a) const {
        modint res(*this);
        return res += a;
    }
    modint operator-(const modint a) const {
        modint res(*this);
        return res -= a;
    }
    modint operator*(const modint a) const {
        modint res(*this);
        return res *= a;
    }
    modint pow(ll t) const {
        if (t == 0) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t % 2 == 1) a *= *this;
        return a;
    }
    modint inv() const {
        return pow(MOD - 2);
    }
    modint &operator/=(const modint a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint a) const {
        modint res(*this);
        return res /= a;
    }
};
struct combination {
    vector<modint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = fact[i - 1] * i;
        }
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) {
            ifact[i - 1] = ifact[i] * i;
        }
    }
    modint operator()(int n, int k) {
        if (n < k || k < 0) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    modint h(int n, int k) {
        n += k - 1;
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(2002002);
int main() {
    int n;
    cin >> n;
    using P = pair<ll, modint>;
    auto f1 = [](P a, P b) {
        return make_pair(a.first + b.first, comb(a.first + b.first, a.first) *
                                                a.second * b.second);
    };
    auto f2 = [](P a, modint d) { return make_pair(a.first + 1, a.second); };

    ReRooting<modint, P> g(n, f1, f2, {0, 1});
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g.add_edge(a, b, -1);
    }

    auto ans = g.solve();
    for (auto x : ans) cout << x.second.value() << endl;
}

Measured memory_bytes: 89204