import java.util.*;
import java.io.*;

public class c{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int e = sc.nextInt();
        for(int i = 0; i < e-1; i++)
        {
            int u = sc.nextInt();
            int v = sc.nextInt();
        }
        for(int i = 0; i < e-1; i++)
        {
            System.out.println(i);
        }
    }
}