#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

struct mint {
	typedef long long ll;
	ll x, m;
	mint(ll x=0, ll m=1e9+7): x((m+x%m)%m), m(m) {}
	mint operator-() const { return mint(m-x, m); }
	mint& operator+=(const mint o) { x=(x+o.x)%m; return *this; }
	mint& operator+=(const ll o) { return (*this)+=mint(o, m); }
	mint& operator-=(const mint o) { return (*this)+=(-o); }
	mint& operator-=(const ll o) { return (*this)-=mint(o, m); }
	mint& operator*=(const mint o) { x = x*o.x%m; return *this; }
	mint& operator*=(const ll o) { return (*this)*=mint(o, m); }
	mint& operator/=(const mint o) { return (*this)*=o.inv(); }
	mint& operator/=(const ll o) { return (*this)/=mint(o, m); }
	friend mint operator+(mint l, const mint r) { l+=r; return l; }
	friend mint operator+(mint l, const ll r) { l+=r; return l; }
	friend mint operator+(const ll l, mint r) { r+=l; return r; }
	friend mint operator-(mint l, const mint r) { l-=r; return l; }
	friend mint operator-(mint l, const ll r) { l-=r; return l; }
	friend mint operator-(const ll l, mint r) { r-=l; return r; }
	friend mint operator*(mint l, const mint r) { l*=r; return l; }
	friend mint operator*(mint l, const ll r) { l*=r; return l; }
	friend mint operator*(const ll l, mint r) { r*=l; return r; }
	friend mint operator/(mint l, const mint r) { l/=r; return l; }
	friend mint operator/(mint l, const ll r) { l/=r; return l; }
	friend mint operator/(const ll l, const mint r) { return mint(l, r.m)/r; }
	bool operator==(const mint o) const { return x==o.x; }
	bool operator!=(const mint o) const { return x!=o.x; }
	friend bool operator==(const ll l, const mint r) { return mint(l, r.m) == r; }
	friend bool operator!=(const ll l, const mint r) { return mint(l, r.m) != r; }

	mint pow(ll k) const {
		if(k==0) return mint(1, m);
		if(k%2) return pow(k-1)*x;
		mint z = pow(k/2);
		return z*z;
	}

	mint inv() const { return pow(m-2); }
};

int _main(){
	for(auto x: std::vector<int>{3, 5, 7, 11, 13, 17, 19}){
		assert((mint(4, x)/mint(4, x))==1);
	}
	return 0;
}

mint fact[500000];

void dfs1(int u, int p, vector<vector<int>> &graph, vector<mint> &ccnt, vector<int> &nch){
	nch[u] = 1;
	ccnt[u] = mint(1);
	for(int v: graph[u]){
		if(v==p) continue;
		dfs1(v, u, graph, ccnt, nch);
		nch[u] += nch[v];
		ccnt[u] *= ccnt[v] / fact[nch[v]];
	}
	ccnt[u] *= fact[nch[u]-1];
}

void dfs2(int u, int p, vector<vector<int>> &graph, vector<mint> &ccnt, vector<int> &nch, vector<mint> &pcnt){
	int n = graph.size();
	mint all(1);
	if(p >= 0) {
		all = pcnt[u] / fact[n-nch[u]];
	}
	for(int v: graph[u]){
		if(v==p) continue;
		all *= ccnt[v] / fact[nch[v]];
	}

	for(int v: graph[u]){
		if(v==p) continue;
		debug("*",u, v, n-nch[v]);
		pcnt[v] = fact[n-nch[v]-1] * all / (ccnt[v] / fact[nch[v]]);
		dfs2(v, u, graph, ccnt, nch, pcnt);
	}
}

void dfs3(int u, int p, vector<vector<int>> &graph, vector<mint> &ccnt, vector<int> &nch, vector<mint> &pcnt, vector<mint> &ans){
	int n = graph.size();
	ans[u] = fact[n-1];
	ans[u] *= pcnt[u] / fact[n-nch[u]];
	for(int v: graph[u]){
		if(v==p) continue;
		ans[u] *= ccnt[v] / fact[nch[v]];
		dfs3(v, u, graph, ccnt, nch, pcnt, ans);
	}
}

int main(){
	int N;
	cin >> N;
	vector<int> A(N-1), B(N-1);
	for(int i=0; i<N-1; i++) cin >> A[i] >> B[i];
	vector<vector<int>> graph(N);
	for(int i=0; i<N-1; i++){
		graph[A[i]-1].push_back(B[i]-1);
		graph[B[i]-1].push_back(A[i]-1);
	}

	fact[0] = mint(1);
	for(int i=1; i<500000; i++) fact[i] = fact[i-1]*i;

	vector<mint> ccnt(N);
	vector<int> nch(N);
	vector<mint> pcnt(N);

	dfs1(0, -1, graph, ccnt, nch);
	debugv(nch);
	vector<ll> dccnt(N);
	for(int i=0; i<N; i++) dccnt[i] = ccnt[i].x;
	debugv(dccnt);

	pcnt[0] = 1;
	dfs2(0, -1, graph, ccnt, nch, pcnt);
	vector<ll> dpcnt(N);
	for(int i=0; i<N; i++) dpcnt[i] = pcnt[i].x;
	debugv(dpcnt);

	vector<mint> ans(N);
	dfs3(0, -1, graph, ccnt, nch, pcnt, ans);

	for(int i=0; i<N; i++){
		cout << ans[i].x << endl;
	}

	return 0;
}


Measured memory_bytes: 36596