You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:

  * Every label is an integer between 0 and n-2 inclusive. 
  * All the written labels are distinct. 
  * The largest value among MEX(u,v) over all pairs of nodes (u,v) is as small as possible. 



Here, MEX(u,v) denotes the smallest non-negative integer that isn't written on any edge on the unique simple path from node u to node v.

Input

The first line contains the integer n (2 ≤ n ≤ 10^5) — the number of nodes in the tree.

Each of the next n-1 lines contains two space-separated integers u and v (1 ≤ u,v ≤ n) that mean there's an edge between nodes u and v. It's guaranteed that the given graph is a tree.

Output

Output n-1 integers. The i^{th} of them will be the number written on the i^{th} edge (in the input order).

Examples

Input


3
1 2
1 3


Output


0
1


Input


6
1 2
1 3
2 4
2 5
5 6


Output


0
3
2
4
1

Note

The tree from the second sample:

<image>
import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
import java.math.BigInteger.*;
import java.util.Arrays; 

public class   Iloveweselyleung1
{
  BufferedReader in;
  StringTokenizer as;
  int  nums[],nums2[];
    Map<Integer,Integer > map = new HashMap<Integer, Integer>();
  ArrayList < Integer >  ar[];
    ArrayList < Integer >  ar2 = new ArrayList < Integer >();
  public static void main (String[] args)
  {
    new Iloveweselyleung1  ();
  }
  
    int findGCD(int number1, int number2) {
        if(number2 == 0){
            return number1;
        }
        return findGCD(number2, number1%number2);
    }
  
  
  public Iloveweselyleung1  ()
  {
    try
    {
      
      in = new BufferedReader (new InputStreamReader (System.in));
      int a = nextInt();
      ar = new ArrayList[a];
      for(int x = 0;x<a;x++)
        ar[x] = new ArrayList < Integer >();
      for(int x = 0;x<a-1;x++)
      {
        int b = nextInt()-1;
        int c = nextInt()-1;
        ar[b].add(c);
        ar[b].add(x);
        ar[c].add(b);
        ar[c].add(x);
      }
      for(int x = 0;x<a;x++)
      {
        if(ar[x].size() == 2)
        {
          ar2.add(ar[x].get(1));
          if(ar2.size() == 3)
            break;
        }
      }
      if(ar2.size() != 3)
      {
        for(int x = 0;x<a-1;x++)
          System.out.println(x);
      }
      else
      {
        int count = 3;
        int count1 = 0;
        for(int x = 0;x<a-1;x++)
        {
          if(x != ar2.get(0) && x != ar2.get(1) && x != ar2.get(2)) 
          {
            System.out.println(count);
            count++;
          }
          else
          {
            System.out.println(count1);
            count1++;
          }
        }
      }
     
    }
    
    
    
    catch(IOException e)
    {
      System.out.println(e);
      
    }
  }
  String next () throws IOException
  {
    while (as == null || !as.hasMoreTokens ())
    {
      as = new StringTokenizer (in.readLine ().trim ());
    }
    
    
    return as.nextToken ();
  }
  
  
  
  long nextLong () throws IOException
  {
    return Long.parseLong (next ());
  }
  
  
  int nextInt () throws IOException
  {
    return Integer.parseInt (next ());
  }
  
  
  double nextDouble () throws IOException
  {
    return Double.parseDouble (next ());
  }
  
  
  String nextLine () throws IOException
  {
    return in.readLine ().trim ();
  }
}