#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

template <std::uint_fast64_t mod>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 x;
    ModInt(const ll x = 0) : x(x < 0 ? (mod - (-x % mod)) % mod : x % mod) {}

    ModInt operator+(const ModInt r) { return ModInt(*this) += r; }
    ModInt operator*(const ModInt r) { return ModInt(*this) *= r; }
    ModInt operator-(const ModInt r) { return ModInt(*this) -= r; }
    ModInt operator/(const ModInt r) { return ModInt(*this) /= r; }
    ModInt operator-() { return ModInt(mod - x); }

    ModInt &operator+=(const ModInt r) {
        x += r.x;
        if (x >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt r) {
        if (x < r.x) x += mod;
        x -= r.x;
        return *this;
    }
    ModInt &operator*=(const ModInt r) {
        x *= r.x;
        if (x >= mod) x %= mod;
        return *this;
    }
    ModInt &operator/=(ModInt r) {
        if (!(x % r.x)) {
            x /= r.x;
            return *this;
        }
        u64 p = mod - 2;
        while (p > 0) {
            if (p & 1) *this *= r;
            r *= r;
            p >>= 1;
        }
        return *this;
    }
    ModInt &operator++(int) { return (*this) += 1; }
    ModInt &operator++() { return (*this) += 1; }
    ModInt &operator--(int) { return (*this) -= 1; }
    ModInt &operator--() { return (*this) -= 1; }

    bool operator<(const ModInt r) { return x < r.x; }
    bool operator>(const ModInt r) { return x > r.x; }
    bool operator<=(const ModInt r) { return x <= r.x; }
    bool operator>=(const ModInt r) { return x >= r.x; }
    bool operator==(const ModInt r) { return x == r.x; }
    bool operator!=(const ModInt r) { return x != r.x; }

    ModInt inv() { return (ModInt)1 / (*this); }
    int get_mod() { return mod; }

    friend std::istream &operator>>(std::istream &in, ModInt &m) {
        ll a;
        in >> a;
        if (a < 0) a = mod - (-a % mod);
        if (a >= mod) a %= mod;
        m.x = a;
        return in;
    }
    friend std::ostream &operator<<(std::ostream &out, const ModInt &m) {
        out << m.x;
        return out;
    }
};
constexpr std::uint_fast64_t mod = 1e9 + 7;
using mint = ModInt<mod>;

template <typename T>
T fact(std::uint_fast32_t n) {
    static vector<T> factorial(1, 1);

    if (n < factorial.size())
        return factorial[n];
    else
        for (T i = factorial.size(); i <= n; i++) {
            factorial.push_back(factorial.back() * i);
        }
    return factorial[n];
}
template <typename T>
T invfact(std::uint_fast32_t n) {
    static vector<T> ifactorial(1, 1);

    if (n < ifactorial.size())
        return ifactorial[n];
    else
        for (T i = ifactorial.size(); i <= n; i++) {
            ifactorial.push_back(ifactorial.back() / i);
        }
    return ifactorial[n];
}

template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    vector<vector<T>> dist;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        dist.assign(V, vector<T>(0));
    }

    void input(bool is_direct, bool inputc, bool index0 = false) {
        int a, b;
        T c = 0;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (inputc) cin >> c;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, c});
            es.push_back((Edge){a, b, c});
            if (!is_direct) {
                edge[b].push_back((Edge){b, a, c});
                es.push_back((Edge){b, a, c});
            }
        }
        if (!is_direct) E *= 2;
    }

    void add_edge(int from, int to, T cost, bool is_direct) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        if (!is_direct) {
            edge[to].push_back({to, from, cost});
            es.push_back({to, from, cost});
            E++;
        }
        E++;
    }

    // 全方位木dp (O(N))
    vector<T> dp;
    vector<int> par;
    vector<int> size;

    T init(int r = 0, int from = -1) {
        par[r] = from;
        if (edge[r].size() == 1 && from != -1) return dp[r] = size[r] = 1;

        T res = 1;
        for (const auto &e : edge[r])
            if (e.to != from) {
                res *= init(e.to, r);
                res *= invfact<mint>(size[e.to]);
                size[r] += size[e.to];
            }
        size[r]++;
        return dp[r] = fact<mint>(size[r] - 1) * res;
    }

    void reroot() {
        dp.resize(V);
        par.resize(V);
        size.assign(V, 0);

        init();
        stack<int> st;
        st.push(0);
        while (!st.empty()) {
            int r = st.top();
            st.pop();
            for (const auto &e : edge[r])
                if (e.to != par[r]) st.push(e.to);
            if (r == 0) continue;

            int p = par[r], sp = size[p];
            mint dpp = dp[p];
            dpp *= invfact<mint>(sp - 1);
            sp = sp - size[r];
            dpp = (dpp / (dp[r] * invfact<mint>(size[r]))) * fact<mint>(sp - 1);

            dp[r] *= invfact<mint>(size[r] - 1);
            dp[r] *= dpp * invfact<mint>(sp) * fact<mint>(V - 1);

            size[r] = V;
        }
    }
};

int main() {
    int N;
    cin >> N;
    fact<mint>(N);
    invfact<mint>(N);
    Graph<mint> tree(N, N - 1);
    tree.input(false, false);
    tree.reroot();
    for (int i = 0; i < N; i++) cout << tree.dp[i] << endl;
    return 0;
}

Measured memory_bytes: 36712