#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
// #include <queue>
// #include <deque>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

// #include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';
const ll M = 1000000007;

ll factmod[200001];
ll dp[200001];
ll dp2[200001];
ll subtree[200001];
ll ret[200001];
bool seen[200001];


/*
Edge cases:


*/

ll modpow(ll b, ll p) {
    if (b==1) return 1;
    ll c = 1;
    ll base = b;
    ll pow = p;

    //inv c*base^pow = b^p;
    // cout<<"calculating "<<b<<" to the "<<p<<" power"<<el;
    while (pow>0) {
        if (pow%(ll)2==0) {
            base*=base;
            base%=M;
            pow/=(ll)2;

        } else {
            c*=base;
            c%=M;
            --pow;
        }
        // cout<<c<<" times "<<base<<" to the "<<pow<<" power"<<el;

    }
    return c;
}


//don't pass x = 0!!
ll invmod(ll x) {
    //x^{p-1} == 1 mod p
    return modpow(x,M-2);
}

//generate factorials up to n!
void genfact(int n) {
    factmod[0]=1;
    ll temp = 1;
    for (int i = 1; i<=n; ++i) {
        temp *= (ll)i;
        temp %= M;
        factmod[i] = temp;
    }
}




int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n; cin>>n; cin.ignore();
    genfact(n);

    vector<vector<int>> neighbors(n+1,vector<int>{});
    
    for (int i=0; i<n-1; ++i) {
        int a,b;
        cin>>a>>b;
        neighbors[a].push_back(b);
        neighbors[b].push_back(a);
    }

    int root = 1;
    stack<int> s; s.push(root);

    while (!s.empty()) {
        //first time: push children;
        //second time: calc subtree; dp;

        int i = s.top();
        if (seen[i]) {
            // cout<<"at node "<<i<<el;
            subtree[i] = 1;
            s.pop();
            ll dpprod = 1;
            ll denom = 1;
            for (int x: neighbors[i]) {
                // cout<<"for node "<<x<<" from perspective of "<<i<<" we see subtree/dp="
                // <<subtree[x]<<","<<dp[x]<<el;
                if (subtree[x]>0) {
                    subtree[i] += subtree[x];
                    dpprod *= dp[x];
                    dpprod %= M;
                    denom *= factmod[subtree[x]];
                    denom %= M;
                    // cout<<"factorial of subtree size "<<subtree[x]<<"="<<factmod[subtree[x]]<<el;
                    // cout<<"inverse mod of "<<subtree[x]<<" factorial = "<<
                    // invmod(factmod[subtree[x]])<<el;
                    // multinom *= invmod(factmod[subtree[x]]);
                    // multinom %= M;
                }
            }


            if (subtree[i]==1) {
                dp[i] = 1;
            } else {
                ll multinom = invmod(denom);
                multinom *= factmod[subtree[i]-1];
                multinom %= M;
                dp[i] = (dpprod*multinom)%M;
            }
        } else {
            seen[i]=true;
            for (int x: neighbors[i]) {
                if (!seen[x]) {
                    s.push(x);
                }
            }
        }
    }

    // for (int i = 1; i<=n; ++i) {
        // cout<<"the tree rooted at "<<i<<" has dp = "<<dp[i]<<" and subtree size = "<<subtree[i]<<el;
    // }

    fill(seen+1,seen+n+1,0);


    //REROOTING;
    stack<pii> st;
    for (int i: neighbors[1]) st.push({1,i});
    seen[1]=true;

    //Already computed the answer for root=1
    ret[1]=dp[1];

    while (!st.empty()) {
        auto p = st.top();
        st.pop();
        int i = p.first, j = p.second;
        //ret[j] needs to be calculated; ret[i] has been done already; j is a child of i;

        // cout<<"considering child "<<j<<" of "<<i<<el;

        ret[j] = ret[i];
        // cout<<"initializing with ret of "<<j<<" equals "<<ret[j]<<el;
        // cout<<"subtree size of "<<j<<" is "<<subtree[j]<<el;
        if (subtree[j]==1) {
            // cout<<"in leaf case "<<el;
            ret[j] *= invmod(n-1);
            ret[j] %= M;
            // cout<<"divided by "<<n-1<<" to get "<<ret[j]<<el;
        } else {
            int r = (int)subtree[j];
            ret[j] *= factmod[r];
            ret[j] %= M;
            ret[j] *= invmod(factmod[r-1]);
            ret[j] %= M;
            ret[j] *= factmod[n-1-r];
            ret[j] %= M;
            ret[j] *= invmod(factmod[(n-r)]);
            ret[j] %= M;

            // cout<<"multiplied by "<<r<<"!="<<factmod[r]<<";  ";
            // cout<<"multiplied by "<<n-1-r<<"!="<<factmod[n-1-r]<<";  ";
            // cout<<"divided by "<<r-1<<"!="<<factmod[r-1]<<";  ";
            // cout<<"divided by n-r"<<"!="<<factmod[n-r]<<el;

        }

        for (int k: neighbors[j]) {
            if (!seen[k]) {
                st.push({j,k});
            }
        }
        
        seen[j]=true;
    }

    for (int i = 1; i<= n; ++i) {
        cout<<ret[i]<<el;
    }




}

Measured memory_bytes: 23668