import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); List edges = new ArrayList<>(); for(int i = 0 ; i < n - 1 ; i++){ int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; Edge edge = new Edge(a , b); edges.add(edge); } Graph graph = new Graph(edges , n); for(int i = 0 ; i < n ; i++){ boolean[] seen = new boolean[n]; seen[i] = true; int ans = 0; ans = dfs(graph , i , seen , ans); System.out.println(ans); } } private static int dfs(Graph graph , int v , boolean[] seen , int ans){ seen[v] = true; for(Edge edge : graph.getEdgsList(v)){ int next_v = edge.getTo(); if(seen[next_v]){ continue; } if(next_v < v){ ans++; } ans = dfs(graph , next_v , seen , ans); } return ans; } } //グラフのエッジ(辺)を格納するクラス class Edge { private int from, to; /**コンストラクタ * @param : from 頂点 * @param : to つながっている頂点 */ Edge(int from, int to) { this.from = from; this.to = to; } public int getFrom(){ return from; } public int getTo(){ return to; } public void setFrom(int from){ this.from = from; } public void setTo(int to){ this.to = to; } } //無向グラフクラス class Graph { //隣接リストを表すリストのリスト(ある頂点が、どの頂点とつながっているかを保持するリスト) Map> edgeMap = new HashMap<>(); /**コンストラクタ * @param edges : 辺 * @param n : 頂点の個数 * */ Graph(List edges, int n) { for (int i = 0; i < n; i++) { edgeMap.put(i ,new ArrayList<>()); } //無向グラフにエッジを追加します for (Edge edge: edges) { int from = edge.getFrom(); int to = edge.getTo(); List tmp1 = edgeMap.get(from); tmp1.add(edge); edgeMap.put(from , tmp1); List tmp2 = edgeMap.get(to); Edge tmpEdge = new Edge(to , from); tmp2.add(tmpEdge); edgeMap.put(to , tmp2); } } public int size() { return edgeMap.size(); } public List getEdgsList(int vNum) { return edgeMap.get(vNum); } }