#ifndef hari64 #include // #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #define debug(...) #else #include "util/viewer.hpp" #define debug(...) viewer::_debug(__LINE__, #__VA_ARGS__, __VA_ARGS__) #endif // clang-format off using namespace std; template using vc = vector; template using vvc = vector>; template using vvvc = vector>; using ll = long long; using ld = long double; using pii = pair; using pll = pair; using tiii = tuple; using tlll = tuple; using vi = vc; using vvi = vvc; using vvvi = vvvc; using vll = vc; using vvll = vvc; using vvvll = vvvc; using vb = vc; using vvb = vvc; using vvvb = vvvc; using vpii = vc; using vvpii = vvc; using vpll = vc; using vvpll = vvc; using vtiii = vc; using vvtiii = vvc; using vtlll = vc; using vvtlll = vvc; #define ALL(x) begin(x), end(x) #define RALL(x) (x).rbegin(), (x).rend() constexpr int INF = 1001001001; constexpr long long INFll = 1001001001001001001; template bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } template bool chmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } // clang-format on int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector> adj(N); for (int i = 0; i < N - 1; i++) { int u, v; cin >> u >> v; u--; v--; adj[u].push_back(v); adj[v].push_back(u); } vi ans(N); for (int i = 0; i < N; i++) { for (auto& v : adj[i]) { ans[i] += int(adj[v].size()) - 1; } } for (auto& elem : ans) cout << elem << '\n'; return 0; }