#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")

#include <stdio.h>
#include <utility>

// 入力
constexpr int MAX_INPUT_SIZE = 2'800'334; //'
char Input[MAX_INPUT_SIZE];
char* input = Input;
char* output = Input;
inline int get(void){
    long long int res = *(long long int*)input; // リトルエンディアン
    const int a = __builtin_ctzll((res & 0x1010101010101010) ^ 0x1010101010101010); // 左にビット寄せ
    input += (a + 4) >> 3;
    res = (res << (68 - a)) & 0x0f0f0f0f0f0f0f0f;
    res = (res * 10 + (res >> 8)) & 0x00ff00ff00ff00ff;
    res = (res * 100 + (res >> 16)) & 0x0000ffff0000ffff;
    res = (res * 10000 + (res >> 32)) & 0x00000000ffffffff;
    return res;
}
// 出力

constexpr int digit = 5;
constexpr int MAX_D_SIZE = 100'000; //'
struct NoName{
    char S[MAX_D_SIZE][digit + 1];
    char T[MAX_D_SIZE][digit + 1];
    constexpr NoName(void): S(), T(){
        for(int i = 0; i < MAX_D_SIZE; ++i){
            int t = i;
            char* ptr = S[i];
            while(t){ *(ptr++) = '0' ^ (t % 10); t /= 10; }
            for(int j = 0, j2 = digit - 1; j < digit; ++j, --j2){
                T[i][j2] = S[i][j] ? S[i][j] : '0';
            }
            --ptr; char* ptr2 = S[i];
            while(ptr2 < ptr){
                const char c = *ptr; 
                *(ptr--) = *ptr2; *(ptr2++) = c;
            }
        }
    }
};
constexpr NoName Da;

inline void writeBuffer(const int n){

    if(n < MAX_D_SIZE){
        const char* ptr = Da.S[n];
        while(*ptr) *(output++) = *(ptr++);
    }
    else{
        const char* ptr1 = Da.T[n % MAX_D_SIZE];
        const char* ptr2 = Da.S[n / MAX_D_SIZE];
        while(*ptr2) *(output++) = *(ptr2++);
        while(*ptr1) *(output++) = *(ptr1++);
    }    
    *(output++) = '\n';
}

// 制約
constexpr int MAX_N = 200'000; //'
constexpr int mod = 1'000'000'007; //'

// 階乗計算
template <const int M> struct shuumai {
public:
    long long int P[M + 1];
    long long int Inv[M + 1];
    long long int inv[M + 1];
    constexpr shuumai(void):P(), Inv(), inv(){
        P[0] = 1; P[1] = 1;
        for(int x = 1, y = 2; x < M; ++x, ++y) P[y] = (P[x] * y) % mod;
        Inv[M] = inverse(P[M]);
        for(int x = M, y = M - 1; x ; --x, --y){
            Inv[y] = (Inv[x] * x) % mod;
            inv[x] = (P[y] * Inv[x]) % mod;
        }
        inv[0] = 1;
    }
    constexpr int inverse(int a) const noexcept {
        int b = mod, u = 1, v = 0;
        while (b) {
            int t = a / b; 
            a -= t * b; { const int tmp = a; a = b; b = tmp; }
            u -= t * v; { const int tmp = u; u = v; v = tmp; }
        }
        if(u < 0) u += mod;
        return u;
    }
};
constexpr shuumai<MAX_N> karashi;

// リスト
struct Node{
    int vertex;
    int next;
};
Node node[2 * MAX_N];
int begin[MAX_N];
int end = 1;
inline void append(const unsigned int u, const unsigned v){
    node[end] = {v, begin[u]}; begin[u] = end++;
    node[end] = {u, begin[v]}; begin[v] = end++;
}

// 擬似stack
int Stack[MAX_N];
int index_stack = 0;

inline void push(const unsigned int value){ Stack[index_stack++] = value; }
inline int top(void){ return Stack[--index_stack];}
inline bool exist(void){ return index_stack; }

// 
bool visited[MAX_N];
int parent[MAX_N];
int order[MAX_N];
int index_order = 0;


int subTree[MAX_N];
int dp[MAX_N];

int main(void){
    fread_unlocked(Input, sizeof(char), MAX_INPUT_SIZE, stdin);
    const int n = get();

    for(int _ = 1; _ < n; ++_) append(get() - 1, get() - 1);
    // DFSの順序決め
    push(0); visited[0] = true; order[index_order++] = 0;
    while(exist()){
        const int v = top();
        for(int idx = begin[v]; idx ; idx = node[idx].next){
            const int nv = node[idx].vertex;
            if(not visited[nv]){ 
                visited[nv] = true; 
                parent[index_order] = v; 
                order[index_order++] = nv; push(nv);  
            }
        }
    }

    for(int i = 0; i < n; ++i) dp[i] = 1;
    // 根からボトムアップにdp値を計算
    for(int i = n - 1; i ; --i){
        const int v = order[i];
        const int nv = parent[i];
        dp[v] = dp[v] * karashi.P[subTree[v]++] % mod;
        dp[nv] = dp[nv] * (dp[v] * karashi.Inv[subTree[v]] % mod) % mod;
        subTree[nv] += subTree[v];
    }

    {
        dp[0] = dp[0] * karashi.P[subTree[0]++] % mod;
    }


    for(int i = 1; i < n; ++i){
        const int v = order[i];
        const int nv = parent[i];
        dp[v] = dp[nv] * (subTree[v] * karashi.inv[n - subTree[v]] % mod) % mod;
    }

    // 出力
    for(int i = 0; i < n; ++i) writeBuffer(dp[i]);
    *output = '\0';
    fwrite_unlocked(Input, sizeof(char), output - Input, stdout);
    return 0;
}

Measured memory_bytes: 12800