Problem:
Score : 400 points

Problem Statement

Given is a tree G with N vertices.
The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.

Consider painting the edges in G with some number of colors.
We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.

Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.

Constraints

2 \le N \le 10^5

1 \le a_i \lt b_i \le N

All values in input are integers.

The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1}

Output

Print N lines.

The first line should contain K, the number of colors used.

The (i+1)-th line (1 \le i \le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \le c_i \le K must hold.

If there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.

Sample Input 1

3
1 2
2 3

Sample Output 1

2
1
2

Sample Input 2

8
1 2
2 3
2 4
2 5
4 7
5 6
6 8

Sample Output 2

4
1
2
3
4
1
1
2

Sample Input 3

6
1 2
1 3
1 4
1 5
1 6

Sample Output 3

5
1
2
3
4
5

Solution in PyPy3 (2.4.0) (judge verdict: Runtime Error)

#ノードクラス
class Node():
    def __init__(self):
        self.name=-1
        self.parent=-1
        self.p_color=0
        self.child=[]
        self.c_color=[]
        self.type=-1
    

#木クラス
class Tree():
    
    
    #作成した瞬間、入力の数だけノードを作る。
    def __init__(self):
        self.tree=[None]
        self.list=[]
        self.node_n=int(input())
        for i in range(self.node_n):
            a=Node()
            a.name=i+1
            self.tree.append(a)
        for i in range(self.node_n-1):
            hen=[int(j) for j in input().split(" ")]
            self.list.append(hen)
            self.tree[hen[0]].child.append(self.tree[hen[1]])
            self.tree[hen[1]].parent=self.tree[hen[0]]
            
        for i in range(1,self.node_n+1):
            node=self.tree[i]
            if node.parent==-1:
                node.type="root"
            elif node.child==[]:
                node.type="leaf"
            else:
                node.type=="other"
        
    def getroot(self):
        return self.tree[1]
    def getleaf(self):
        leaf=[]
        for i in self.tree:
            if i.type=="leaf":
                leaf.append(i)
        return leaf
    
    def gettree(self):
        return self.tree[:]

    
        
    
    
#木の作成
tree=Tree()


#使った色リスト
colorlist=[]


#調べたリスト
# checklist=tree.gettree()
# checklist.pop(0)
# checklist.pop(0)
# print("checklist",[i.name for i in checklist])

colvar=[tree.node_n-int(i) for i in range(tree.node_n) ]
node=tree.getroot()




def haihai(node):
    print("node",node.name)
    parentcolor=node.p_color
    children=node.child
    if children==[]:
        pass
    else:
        print("children",[i.name for i in children])
        childcolor=colvar.copy()
        if parentcolor in childcolor:
            childcolor.remove(parentcolor)
        for child in children:
            print("childname",child.name)
#             checklist.remove(child)
            color=childcolor.pop()
            child.p_color=color
            if color not in colorlist :
                colorlist.append(color)
            haihai(child)
            

haihai(node)

print(colorlist)

print(len(colorlist))


for j in [tree.tree[i[1]].p_color for i in tree.list]:
    print(j)