#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

void solve(){

}

#else

const int MAXN = 2e5 + 9;

ll answr[MAXN];
ll dp[MAXN];

vector<int> g[MAXN];

ll fact[MAXN];
ll bfact[MAXN];
ll mod = 1e9 + 7;

ll bin_pow(ll base, ll power) {
    if (power == 0)
        return 1;
    if (power % 2 == 1) {
        return (base * bin_pow(base, power - 1)) % mod;
    }
    auto v = bin_pow(base, power >> 1);
    return (v * v) % mod;
}

void precalc() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = (fact[i - 1] * i) % mod;
    }

    for (int i = 0; i < MAXN; ++i) {
        bfact[i] = bin_pow(fact[i], mod - 2);
    }
}

int subtree[MAXN];

ll getnCr(int n, int r) {
    ll ret = fact[n];
    ret *= bfact[r];
    ret %= mod;
    ret *= bfact[n - r];
    ret %= mod;
    return ret;
}

int dfs(int vertex, int par = - 1) {
    int ret = 1;
    ll answ = 1;

    for (auto out : g[vertex]) {
        if (out != par) {
            ret += dfs(out, vertex);
        }
    }

    subtree[vertex] = ret;
    int left = subtree[vertex] - 1;

    for (auto out : g[vertex]) {
        if (out != par) {
            answ *= (getnCr(left, subtree[out]) * dp[out]) % mod;
            left -= subtree[out];
            answ %= mod;
        }
    }

    dp[vertex] = answ;
    return ret;
}


ll get_back(ll elem){
    return bin_pow(elem, mod - 2);
}

int n;

ll recalc(int vertex, int from){
    answr[vertex] = dp[vertex];

    for (auto out : g[vertex]) {
        if (out != from) {
            ll old = dp[vertex];

            ll other = (getnCr(n - 1, subtree[out]) * dp[out] )% mod;

            ll back = get_back(other);

            dp[vertex] *= back;
            dp[vertex] %= mod;

            dp[out] *= (getnCr(n - 1, n - subtree[out]) * dp[vertex]) % mod;
            dp[out] %= mod;

            recalc(out, vertex);

            dp[vertex] = old;
        }
    }
}

void solve() {
    precalc();
    cin >> n;

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

    dfs(1);
    answr[1] = dp[1];
    recalc(1, 1);

    for (int i = 1; i <= n; ++ i){
        cout << answr[i] << "\n";
    }

}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++)  << ": ";
        solve();
//        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

#ifdef LOCAL
    //cout << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 20980