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.
n = int(input())
tree = [[] for i in range(n+1)]
for i in range(n-1):
    a, b = map(int, input().split())
    tree[a].append([b, i+1])
    tree[b].append([a, i+1])

edge = [0] * n #ans
visit = [False] * (n+1) #vert
color = [set() for i in range(n+1)]
visit[1] = True
q = [1]
edge[1] = 1
color[1].add(1)

while q:
    now = q.pop()
    c = 1
    for next, num in tree[now]:
        if not visit[next]:
            while c in color[now]:
                c += 1
            edge[num] = c
            color[next].add(c)
            visit[next] = True
            q.append(next)
            c += 1
    before = now

print(max(edge))
for i in range(1, n):
    print(edge[i])

n = int(input())
tree = [[] for i in range(n+1)]
for i in range(n-1):
    a, b = map(int, input().split())
    tree[a].append([b, i+1])
    tree[b].append([a, i+1])

edge = [0] * n #ans
visit = [False] * (n+1) #vert
color = [set() for i in range(n+1)]
visit[1] = True
q = [1]
edge[1] = 1

while q:
    now = q.pop()
    c = 1
    for next, num in tree[now]:
        if not visit[next]:
            while c in color[now]:
                c += 1
            edge[num] = c
            color[next].add(c)
            visit[next] = True
            q.append(next)
            c += 1
    before = now

print(max(edge))
for i in range(1, n):
    print(edge[i])
