#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;


struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

mint COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return mint(fac[n] * (finv[k] * finv[n - k] % mod) % mod);
}

mint LCOM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (k > n / 2) k = n - k;
	mint res = 1;
	for (int i = 0; i < k; i++) res *= (n - i);
	res *= finv[k];
	return res;
}
int n;
vector<vector<int>> g;
vector<int> sz;
vector<mint> dp;
vector<mint> res;
void dfs1(int cur, int pre) {
	sz[cur] = 1;
	for (auto nxt : g[cur]) {
		if (nxt == pre) continue;
		dfs1(nxt, cur);
		sz[cur] += sz[nxt];
	}
	dp[cur] = 1;
	int rm = sz[cur] - 1;
	for (auto nxt : g[cur]) {
		if (nxt == pre) continue;
		dp[cur] *= COM(rm, sz[nxt]) * dp[nxt];
		rm -= sz[nxt];
	}
}

void dfs2(int cur, int pre) {
	int n = g[cur].size();
	vector<mint> ld(n + 1, 1), rd(n + 1, 1), ls(n + 1, 1), rs(n + 1, 1);
	for (int i = 0; i < n; i++) ld[i + 1] = ld[i] * dp[g[cur][i]], ls[i + 1] = ls[i] * finv[sz[g[cur][i]]];
	for (int i = n - 1; i >= 0; i--) rd[i] = rd[i + 1] * dp[g[cur][i]], rs[i] = rs[i + 1] * finv[sz[g[cur][i]]];
	dp[cur] = ld.back() * ls.back() * fac[sz[cur] - 1];
	res[cur] = dp[cur];
	for (int i = 0; i < n; i++) {
		int nxt = g[cur][i];
		if (nxt == pre) continue;
		sz[cur] -= sz[nxt];
		mint pcur = dp[cur];
		mint pnxt = dp[nxt];
		dp[cur] = ld[i] * rd[i + 1] * fac[sz[cur] - 1] * ls[i] * rs[i + 1];
		sz[nxt] += sz[cur];
		dfs2(nxt, cur);
		sz[nxt] -= sz[cur];
		sz[cur] += sz[nxt];
		dp[cur] = pcur;
		dp[nxt] = pnxt;
	}
}
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	COMinit();
	cin >> n;
	g.resize(n); dp.resize(n); sz.resize(n), res.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v; cin >> u >> v;
		u--; v--;
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	dfs1(0, -1);
	dfs2(0, -1);
	for (int i = 0; i < n; i++) cout << res[i].x << "\n";
	return 0;
}

Measured memory_bytes: 142088