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: Wrong Answer)

//Link : https://codeforces.com/contest/1253

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005
#define mod 1000000007
/*
#include <limits.h>
INT_MAX
LLONG_MAX
*/
int add(int x,int y) {
  return ((x+y)%mod+mod)%mod;
}
int mul(int x,int y) {
  return (ll)x*y%mod;
}
int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    x = mul(x,x);
    c/=2;
  }
  return ret;
}

int fac[N],invFac[N];
int combi(int n,int r) {
  if(n<r) {
    return 0;
  }
  int ret = mul(fac[n],invFac[r]);
  ret = mul(ret, invFac[n-r]);
  return ret;
}

vector<int> adj[N];
int dp[N],subSize[N],out[N];

void dfs(int node,int par) {
  subSize[node] = 1;
  dp[node] = 1;
  for(int ch : adj[node]) {
    if(ch == par) {
      continue;
    }
    dfs(ch,node);
    subSize[node] += subSize[ch];
    dp[node] = mul(dp[ch], invFac[subSize[ch]]);
  }
  dp[node] = mul(dp[node], fac[subSize[node]-1]);
}

void dfs2(int node,int par,int n,int tmpDp) {
  int r = mul(dp[node],invFac[subSize[node]-1]);
  r = mul(r, mul(fac[n-1], mul(invFac[n-subSize[node]], tmpDp)));
  out[node] = r;
  for(int ch : adj[node]) {
    if(ch == par) {
      continue;
    }
    int nextDp = mul(dp[node],invFac[subSize[node]-1]);
    nextDp = mul(nextDp, fac[n-subSize[ch]-1]);
    nextDp = mul(nextDp, mypow(dp[ch],mod-2));
    nextDp = mul(nextDp, fac[subSize[ch]]);
    nextDp = mul(nextDp, mul(tmpDp,invFac[n-subSize[node]]));
    dfs2(ch,node,n,nextDp);
  }
}

void solve() {
  fac[0] = invFac[0] = 1;
  for(int i=1;i<N;++i) {
    fac[i] = mul(fac[i-1],i);
    invFac[i] = mypow(fac[i],mod-2);
  }
  int n;
  scanf("%d ", &n);
  for(int i=0;i<n-1;++i) {
    int a,b;
    scanf("%d %d ", &a,&b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1,0);
  dfs2(1,0,n,1);
  for(int i=1;i<=n;++i) {
    printf("%d\n", out[i]);
  }
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}