using System.Collections.Generic; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); getAns(n); } static void getAns(int n) { var aa = new List[n]; for (int i = 0; i < n; i++) aa[i] = new List(); for (int i = 0; i < n - 1; i++) { string[] line = Console.ReadLine().Trim().Split(' '); var a = int.Parse(line[0]) - 1; var b = int.Parse(line[1]) - 1; aa[a].Add(b); aa[b].Add(a); } var ans = new int[n]; foreach (var x in aa) { var m = x.Count; if (m <= 1) continue; for (int i = 0; i < m - 1; i++) for (int j = i + 1; j < m; j++) { ans[x[i]]++; ans[x[j]]++; } } Console.WriteLine(string.Join("\n", ans)); } }