#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; }

vector<pair<FiniteField, int>> ReRooting(const vector<vector<Edge>>& graph) {
  int n = graph.size();

  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 add_root_fn = [&](pair<FiniteField, int> o) -> pair<FiniteField, int> {
    return {o.first, o.second + 1};
  };

  pair<FiniteField, int> identity = {1, 0};

  vector<pair<FiniteField, int>> 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] = add_root_fn(a);
  };
  dfs_1_fn(0, -1);

  vector<pair<FiniteField, int>> dp_2(n);
  function<void(int, int, pair<FiniteField, int>)> dfs_2_fn = [&](int v, int p, pair<FiniteField, int> 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<pair<FiniteField, int>> 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<pair<FiniteField, int>> 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] = add_root_fn(merge_fn(ls[m], p_value));

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

  return dp_2;
}

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

  int n;
  cin >> n;

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

  auto solution = ReRooting(graph);
  for (int i = 0; i < n; i++) {
    cout << solution[i].first << "\n";
  }
}

Measured memory_bytes: 31580