#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    vector<int> solve(int n, vector<pair<int,int>>& edges) {
        const int MOD = 1e9 + 7;

        auto norm = [&](long long a) {
            a %= MOD;
            if (a < 0) {
                a += MOD;
            } 
            if (a >= MOD) {
                a -= MOD;
            }
            return a;
        };

        auto inverse = [&](long long a) {
            long long b = MOD;
            long long u = 0, v = 1;
            
            a = norm(a);
            while (a != 0) {
                long long d = b / a;
                b -= d * a;
                u -= d * v;
                swap(a, b);
                swap(u, v);
            }
            u = norm(u);
            return u;
        };

        vector<vector<int>> graph(n);
        for (auto& e : edges) {
            int u = e.first, v = e.second;
            graph[u].push_back(v);
            graph[v].push_back(u);
        }

        vector<int> res(n, 0);

        vector<int> F(n + 1, 1);
        vector<int> IF(n + 1, 1);
        for (int i = 1; i <= n; ++i) {
            F[i] = (F[i - 1] * 1LL * i) % MOD;
        }
        IF[n] = inverse(F[n]);
        for (int i = n - 1; i > 0; --i) {
            IF[i] = (IF[i + 1] * 1LL * (i + 1)) % MOD;
            assert((IF[i] * 1LL * F[i]) % MOD == 1);
        }

        auto nCr = [&](int n, int r) {
            long long res = F[n] * 1LL * IF[r] % MOD * 1LL * IF[n - r] % MOD;
            return res;
        };


        vector<int> ord;
        vector<bool> visited(n, false);
        vector<int> pars(n, -1);
        int rt = 0;
        ord.push_back(rt);
        visited[rt] = true;
        for (int i = 0; i < ord.size(); ++i) {
            int u = ord[i];
            for (auto v : graph[u]) {
                if (!visited[v]) {
                    visited[v] = true;
                    pars[v] = u;
                    ord.push_back(v);
                }
            }
        }
        assert(ord.size() == n);
        vector<int> sizes(n, 0);

        reverse(ord.begin(), ord.end());
        vector<int> down(n, 0);

        for (auto u : ord) {
            sizes[u] = 0;

            for (auto v : graph[u]) {
                if (v == pars[u]) {
                    continue;
                }
                sizes[u] += sizes[v];
            }

            long long cnt = 1;
            int sz = sizes[u];
            for (auto v : graph[u]) {
                if (v == pars[u]) {
                    continue;
                } 
                cnt = (cnt * down[v]) % MOD;
                cnt = (cnt * nCr(sz, sizes[v])) % MOD;
                sz -= sizes[v];
            }

            down[u] = cnt;
            sizes[u] += 1;
        }

        reverse(ord.begin(), ord.end());
        vector<int> up(n, 0);
        up[rt] = 1;

        vector<pair<int,int>> cnts(n + 123);
        for (auto u : ord) {
            int sz = 0;
            cnts[sz++] = make_pair(up[u], n - sizes[u]);
            for (auto v : graph[u]) {
                if (v == pars[u]) {
                    continue;
                }
                cnts[sz++] = make_pair(down[v], sizes[v]);
            }
            long long val = 1;
            int rem = n - 1;
            for (int i = 0; i < sz; ++i) {
                int c = cnts[i].first;
                int r = cnts[i].second;
                val = val * c % MOD;
                val = val * nCr(rem, r) % MOD;
                rem -= r;
            }
            res[u] = val;

            for (auto v : graph[u]) {
                if (v == pars[u]) {
                    continue;
                }
                up[v] = res[u] * inverse(down[v]) % MOD * inverse(nCr(n - 1, sizes[v])) % MOD;
            }
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int,int>> edges;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        edges.emplace_back(u, v);
    }
    Solution sol;
    auto res = sol.solve(n, edges);
    for (auto r : res) {
        cout << r << "\n";
    }
    return 0;
}

Measured memory_bytes: 21616