#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 raw_x) : x(raw_x) {
    if (x >= P || x < 0) {
    x %= P;
    if (x < 0) x += P;
  }
}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};
ostream& operator<<(ostream& s, const FiniteField& x) { s << x.Value(); return s; }

// Semantics:
// Suppose a rooted tree T has subtrees S_1, ... ,S_m.
// f(T) = finalize_fn(reduce({f(S_1), ..., f(S_m)}, identity, merge_fn)).
template <typename T, typename U>
vector<T> ReRooting(
    const vector<vector<Edge>>& graph,
    function<U(U, T)> merge_fn,
    function<T(U)> finalize_fn,
    U identity) {
  int n = graph.size();

  vector<T> dp_1(n);
  function<void(int, int)> dfs_1_fn = [&](int v, int p) {
    auto a = identity;
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      dfs_1_fn(e.to, v);
      a = merge_fn(a, dp_1[e.to]);
    }
    dp_1[v] = finalize_fn(a);
  };
  dfs_1_fn(0, -1);

  vector<T> dp_2(n);
  function<void(int, int, T)> dfs_2_fn = [&](int v, int p, T p_value) {
    vector<int> us;
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      us.push_back(e.to);
    }
    int m = us.size();

    vector<U> ls(m + 1);
    ls[0] = identity;
    for (int i = 0; i < m; i++) {
      ls[i + 1] = merge_fn(ls[i], dp_1[us[i]]);
    }
    vector<U> rs(m + 1);
    rs[m] = identity;
    for (int i = m - 1; i >= 0; i--) {
      rs[i] = merge_fn(rs[i + 1], dp_1[us[i]]);
    }

    dp_2[v] = finalize_fn(merge_fn(merge_fn(identity, ls[m]), p_value));

    for (int i = 0; i < m; i++) {
      dfs_2_fn(
          us[i], v,
          finalize_fn(
              merge_fn(merge_fn(merge_fn(identity, ls[i]), rs[i + 1]), p_value)));
    }
  };
  dfs_2_fn(0, -1, identity);

  return dp_2;
}

template <typename T>
vector<T> ReRooting(
    const vector<vector<Edge>>& graph,
    function<T(T, T)> merge_fn,
    function<T(T)> finalize_fn,
    T identity) {
  return ReRooting<T, T>(graph, merge_fn, finalize_fn, identity);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;

  auto graph = ReadUndirectedGraph(n, n - 1, true);

  vector<FiniteField> factorials(n + 1);
  factorials[0] = 1;
  for (int i = 1; i <= n; i++) {
    factorials[i] = factorials[i - 1] * i;
  }

  auto merge_fn = [&](pair<FiniteField, int> o1, pair<FiniteField, int> o2) -> pair<FiniteField, int> {
    const auto[c1, s1] = o1;
    const auto[c2, s2] = o2;
    return {c1 * c2 * factorials[s1 + s2] / factorials[s1] / factorials[s2], s1 + s2};
  };

  auto finalize_fn = [&](pair<FiniteField, int> o) -> pair<FiniteField, int> {
    return {o.first, o.second + 1};
  };

  auto solution = ReRooting<pair<FiniteField, int>>(graph, merge_fn, finalize_fn, {1, 0});
  for (int i = 0; i < n; i++) {
    cout << solution[i].first << "\n";
  }
}

Measured memory_bytes: 35780