Problem:
Score : 600 points

Problem Statement

We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.
For each k=1, ..., N, solve the problem below:

Consider writing a number on each vertex in the tree in the following manner:

First, write 1 on Vertex k.

Then, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows:

Choose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random.

Find the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).

Constraints

2 \leq N \leq 2 \times 10^5

1 \leq a_i,b_i \leq N

The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
a_1 b_1
:
a_{N-1} b_{N-1}

Output

For each k=1, 2, ..., N in this order, print a line containing the answer to the problem.

Sample Input 1

3
1 2
1 3

Sample Output 1

2
1
1

The graph in this input is as follows:

For k=1, there are two ways in which we can write the numbers on the vertices, as follows:

Writing 1, 2, 3 on Vertex 1, 2, 3, respectively

Writing 1, 3, 2 on Vertex 1, 2, 3, respectively

Sample Input 2

2
1 2

Sample Output 2

1
1

The graph in this input is as follows:

Sample Input 3

5
1 2
2 3
3 4
3 5

Sample Output 3

2
8
12
3
3

The graph in this input is as follows:

Sample Input 4

8
1 2
2 3
3 4
3 5
3 6
6 7
6 8

Sample Output 4

40
280
840
120
120
504
72
72

The graph in this input is as follows:

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n;
LL fact[1000000+10]={1};
vector<int> each[1000000+20];
const int MOD=1e9+7;
LL quick(LL A,LL B){
	if(B==0){
		return 1;
	}
	LL tmp=quick(A,B>>1);
	if(B&1){
		return tmp*tmp%MOD*A%MOD;
	}
	return tmp*tmp%MOD;
}
LL C(int A,int B){
	if(A==B) return 1;
	return fact[A]*quick(fact[A-B],MOD-2)%MOD*quick(fact[B],MOD-2)%MOD;
}
vector<LL>  dp[1000000+20],cnt[1000000+20];
map<int,int> is[1000000+10];
map<mp,int> vis;
void dfs(int now,int prev){
	if(vis[II(now,prev)]){
		return ;
	}
	int SAVE=prev;
	vis[II(now,prev)]=1;
	prev=each[now][prev];
	for(auto it:each[now]){
		if(it!=-1)
		if(it!=prev){
			dfs(it,is[it][now]);
		}
	}
	cnt[now][SAVE]=1;
	for(auto it:each[now]){
		if(it!=-1){
			if(it!=prev){
				cnt[now][SAVE]+=cnt[it][is[it][now]];
			}
		}
	}
//	cout<<cnt[now][SAVE]<<endl;
	int rest=cnt[now][SAVE]-1;
	dp[now][SAVE]=1ll; 
	for(auto it:each[now]){
		if(it!=-1){
			if(it!=prev){
				dp[now][SAVE]*=dp[it][is[it][now]]*C(rest,cnt[it][is[it][now]])%MOD;
				dp[now][SAVE]%=MOD;
				rest-=cnt[it][is[it][now]];
			}
		}	
	} 
}
int main(){
	fastio;
	
	freopen("test.in","r",stdin);
	cin>>n;
	rb(i,1,n){
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	
	int u,v;
	rb(i,1,n){
		each[i].PB(-1);
	}
	rb(i,2,n){
		cin>>u>>v;
		each[u].PB(v);
		each[v].PB(u);
	}
	rb(i,1,n){
		dp[i]=vector<LL> (each[i].size(),0);
		cnt[i]=dp[i];
	}
	rb(i,1,n){
		rep(j,each[i].size()){
			is[i][each[i][j]]=j;
		}
	}
	rb(i,1,n){
		rep(j,each[i].size()){
			if(vis.find(II(i,j))!=vis.end()){
				continue;
			}
			dfs(i,j);
		}
	}	
	rb(i,1,n){
		cout<<dp[i][0]<<endl;
	}
	return 0;
}