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: Accepted)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
};
typedef ModInt<1000000007> mint;

ll n,visited[200010]={};
V<ll> v[200010],v_rev[200010];
V<pair<mint,mint>> dp[200010],ru[200010],ru_inv[200010];
mint nf=1;

pair<mint,mint> f(ll p, ll rev, bool begin){
	ll k = v[p].size();
	mint sum=1, ans=1;
	if(visited[p] < k){
		rep(i,k){
			if(i==rev)continue;
			if(dp[p][i].first.get()==0){
				dp[p][i] = f(v[p][i],v_rev[p][i],false);
				visited[p]++;
			}
			sum+=dp[p][i].first;
			ans*=dp[p][i].second;
		}
	}else{
		if(visited[p]==k){  // 累積和未計算
			ru[p][0]=dp[p][0];
			reg(i,1,k-1){
				ru[p][i].first = dp[p][i].first + ru[p][i-1].first;
				ru[p][i].second = dp[p][i].second * ru[p][i-1].second;
			}
			ru_inv[p][k-1]=dp[p][k-1];
			irep(i,k-1){
				ru_inv[p][i].first = dp[p][i].first + ru_inv[p][i+1].first;
				ru_inv[p][i].second = dp[p][i].second * ru_inv[p][i+1].second;
			}
			visited[p]+=10;
		}
		if(begin){  // 最初だけは全方向の積が答え
			sum+=ru[p][k-1].first;
			ans*=ru[p][k-1].second;
		}else{
			if(rev>0){
				sum+=ru[p][rev-1].first;
				ans*=ru[p][rev-1].second;
			}
			if(rev<k-1){
				sum+=ru_inv[p][rev+1].first;
				ans*=ru_inv[p][rev+1].second;
			}
		}
	}
	// printf("(%lld,%lld) = (%lld,%lld)\n",par,id,sum.get(),(ans*sum).get());
	return {sum,ans*sum};
}

int main(void){
	cin>>n;
	rep(i,n-1){
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
		v_rev[a].push_back(v[b].size()-1);
		v_rev[b].push_back(v[a].size()-1);
		dp[a].push_back({0,0});
		dp[b].push_back({0,0});
		ru[a].push_back({0,0});
		ru_inv[a].push_back({0,0});
		ru[b].push_back({0,0});
		ru_inv[b].push_back({0,0});
	}
	reg(i,1,n)nf*=i;
	reg(i,1,n){
		cout<<(nf/f(i,-1,true).second).get()<<endl;
	}
	return 0;
}