// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int qpow(const int&b, const int&e) {
	if(!e) return 1;
	if(!(e&1)) return qpow(1ll*b*b%MOD,e>>1);
	return 1ll*b*qpow(b,e-1)%MOD;
}

vector<int> elist[200005];
int fact[200005];
int ssiz[200005];
int way[200005];
int N;

int dfs1(int node, int fa) {
	ssiz[node] = way[node] = 1;
	if(fa != -1 && elist[node].size() == 1) return 1;
	for(int& v:elist[node]) {
		if(v == fa) continue;
		int re = dfs1(v, node);
		ssiz[node] += ssiz[v];
		way[node] = 1ll*way[node]*qpow(fact[ssiz[v]], MOD-2)%MOD;
		way[node] = 1ll*way[node]*re%MOD;
	}
	way[node] = 1ll*way[node]*fact[ssiz[node]-1]%MOD;
	return way[node];
}

int answer[200005];

void dfs2(int node, int fa) {
	answer[node] = way[node];
	for(int& v:elist[node]) {
		if(v == fa) continue;
		// currently rooted at node
		// reroot at v
		int psn = ssiz[node], psv = ssiz[v];
		int pwv = way[v];
		ssiz[node] -= psv;
		way[node] = 1ll*way[node]*qpow(fact[psn-1], MOD-2)%MOD;
		way[node] = 1ll*way[node]*fact[ssiz[node]-1]%MOD;
		way[node] = 1ll*way[node]*qpow(pwv, MOD-2)%MOD; // undo line 61
		way[node] = 1ll*way[node]*fact[psv]%MOD; // undo line 61
		ssiz[v] = psn;
		way[v] = 1ll*way[v]*qpow(fact[psv-1], MOD-2)%MOD;
		way[v] = 1ll*way[v]*fact[ssiz[v]-1]%MOD;
		way[v] = 1ll*way[v]*qpow(fact[ssiz[node]], MOD-2)%MOD;
		way[v] = 1ll*way[v]*way[node]%MOD;
		dfs2(v, node);
		ssiz[node] = psn; ssiz[v] = psv;
		way[node] = answer[node]; way[v] = pwv;
	}
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; gi(n);
	N = n;
	fact[0] = 1;
	rep1(i, n) fact[i] = 1ll*fact[i-1]*i%MOD;
	rep(i, n-1) {
		int u, v; gi(u), gi(v);
		elist[u].pb(v); elist[v].pb(u);
	}
	dfs1(1, -1);
	dfs2(1, -1);
	rep1(i,n) print(answer[i]), pc('\n');
}


Measured memory_bytes: 20608