#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
struct mint;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*, mint>> 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; }
	friend ostream& operator<<(ostream &os, const mint x) { return os << x.x; }

	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); }
};

mint fact[500000];
mint fact_inv[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_inv[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_inv[n-nch[u]];
	}
	for(int v: graph[u]){
		if(v==p) continue;
		all *= ccnt[v] * fact_inv[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_inv[n-nch[u]];
	for(int v: graph[u]){
		if(v==p) continue;
		ans[u] *= ccnt[v] * fact_inv[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;
	fact_inv[0] = mint(1);
	for(int i=1; i<500000; i++) fact_inv[i] = fact_inv[i-1]/i;

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

	dfs1(0, -1, graph, ccnt, nch);
	pcnt[0] = 1;
	dfs2(0, -1, graph, ccnt, nch, pcnt);
	vector<mint> ans(N);
	dfs3(0, -1, graph, ccnt, nch, pcnt, ans);

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

	return 0;
}


Measured memory_bytes: 41332