#include #define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++) using i64 = std::int64_t; template struct Edge { int to; T cost; Edge(int _to, T _cost = 1) : to(_to), cost(_cost) {} }; template struct Graph : std::vector>> { using std::vector>>::vector; void add_edge(int u, int v, T w, bool directed = false) { (*this)[u].emplace_back(v, w); if (directed) return; (*this)[v].emplace_back(u, w); } }; struct graph : std::vector> { using std::vector>::vector; void add_edge(int u, int v, bool directed = false) { (*this)[u].emplace_back(v); if (directed) return; (*this)[v].emplace_back(u); } }; int main() { int n; std::cin >> n; graph g(n); std::vector deg(n, 0); rep(i,0,n-1) { int u,v; std::cin >> u >> v; u--; v--; g.add_edge(u, v); deg[u]++; deg[v]++; } rep(i,0,n) { int ans = 0; for(auto nv: g[i]) { ans += deg[nv] - 1; } std::cout << ans << '\n'; } }