#include #include #include using namespace std; using namespace atcoder; #define get(type, n) type n; cin >> n; #define print(n) cout << (n) << endl #define rep(i, l, n) for (int i = (l); i < (n); i++) #define ite(i, a) for(auto& i : a) #define all(x) x.begin(), x.end() #define lb lower_bound #define ub upper_bound #define lbi(A, x) (ll)(lb(all(A), x) - A.begin()) #define ubi(A, x) (ll)(ub(all(A), x) - A.begin()) using str = string; using ll = long long; using Pair = pair; using mint = modint1000000007; using Mint = modint998244353; template using V = vector; template using VV = V >; const ll INF = 9223372036854775807; const int inf = 2147483647; const ll mod = 1000000007; const ll MOD = 998244353; template inline V getList(int n) { V res(n); rep(i, 0, n) { cin >> res[i]; }return res; } template inline VV getGrid(int m, int n) { VV res(m, V(n)); rep(i, 0, m) { res[i] = getList(n); }return res; } template inline void prints(V& vec) { cout << vec[0]; rep(i, 1, vec.size()) { cout << ' ' << vec[i]; } cout << '\n'; } inline V dtois(string& s) { V vec = {}; ite(e, s) { vec.push_back(e - '0'); } return vec; } int count(map, int>& mp,VV& route, int a, int b) { if (mp.find({ a,b }) != mp.end()) { return mp[{a, b}]; } mp[{a, b}] = 0; ite(nv, route[b]) { if (nv == a) { continue; } mp[{a, b}] += count(mp, route, b, nv); } mp[{a, b}] += (a > b); return mp[{a, b}]; } int main(void) { get(int, n); VV route(n, V(0)); map, int> mp = {}; rep(i, 0, n - 1) { int a, b; cin >> a >> b; a--; b--; route[a].push_back(b); route[b].push_back(a); } rep(i, 0, n) { int ans = 0; ite(nv, route[i]) { ans += count(mp, route, i, nv); } print(ans); } return 0; }