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 Pascal (FPC 2.6.2) (judge verdict: Accepted)

const M=1000000007;
var
	N,i,a,b:Longint;
	c,dp,ans:Array[1..200000]of int64;
	fac,invfac:Array[0..199999]of int64;
	V,nxt:Array[1..399998]of Longint;
	beg:Array[1..200000]of Longint;
function power(a,b:int64):int64;
begin
	if b=0 then power:=1 else if b mod 2=0 then power:=power(a*a mod M,b div 2)else power:=power(a*a mod M,b div 2)*a mod M;
end;
function dfs1(u,p:Longint):int64;
var
	id:Longint;
	ret:int64;
begin
	ret:=1;
	c[u]:=1;
	id:=beg[u];
	while id<>0 do begin
		if V[id]<>p then begin
			ret:=ret*dfs1(V[id],u)mod M;
			ret:=ret*invfac[c[V[id]]]mod M;
			inc(c[u],c[V[id]]);
		end;
		id:=nxt[id];
	end;
	dp[u]:=ret;
	dfs1:=ret*fac[c[u]-1]mod M;
end;
procedure dfs2(u,p:Longint;pr:int64);
var id:Longint;
begin
	ans[u]:=dp[u]*pr mod M*invfac[N-c[u]]mod M;
	id:=beg[u];
	while id<>0 do begin
		if V[id]<>p then begin
			dfs2(V[id],u,ans[u]*c[V[id]]mod M*power(dp[V[id]],M-2)mod M*fac[N-c[V[id]]-1]mod M);
		end;
		id:=nxt[id];
	end;
end;
begin
	read(N);
	fac[0]:=1;
	for i:=1 to N-1 do fac[i]:=fac[i-1]*i mod M;
	invfac[N-1]:=power(fac[N-1],M-2);
	for i:=N-2 downto 0 do invfac[i]:=invfac[i+1]*(i+1)mod M;
	for i:=1 to N-1 do begin
		read(a,b);
		V[i*2-1]:=b;
		nxt[i*2-1]:=beg[a];
		beg[a]:=i*2-1;
		V[i*2]:=a;
		nxt[i*2]:=beg[b];
		beg[b]:=i*2;
	end;
	dfs1(1,0);
	dfs2(1,0,1);
	for i:=1 to N do writeln(ans[i]*fac[N-1]mod M);
end.