import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] x_arr = new int[n - 1];
        int[] y_arr = new int[n - 1];
        for (int i = 0; i < n - 1; ++i) {
            x_arr[i] = scanner.nextInt();
            y_arr[i] = scanner.nextInt();
        }
        int[] counter = new int[n];
        for (int i = 0; i < n - 1; ++i) {
            int temp;
            temp = x_arr[i];
            counter[temp - 1]++;
            temp = y_arr[i];
            counter[temp - 1]++;
        }
        int[] weights = new int[n - 1];
        for (int i = 0; i < n-1; ++i) {
            weights[i] += counter[x_arr[i] - 1];
            weights[i] += counter[y_arr[i] - 1];
//            System.out.println("Weight "+i+" = "+weights[i]);
        }

        int[] cnt = new int[n - 1];
        for (int i = 0; i < n - 1; ++i) {
            for (int j = 0; j < n - 1; ++j) {
                if (i != j) {
                    if (weights[i] > weights[j])
                        cnt[i]++;
                }
            }
//            System.out.println("Count "+i+" = "+cnt[i]);
        }
        boolean[] check = new boolean[n];
        for (int i = 0; i < n - 1; ) {
            if (check[cnt[i]]) {
                cnt[i]++;
            } else {
                check[cnt[i]] = true;
                System.out.println(cnt[i]);
                i++;
            }
        }
    }
}
