import sys

sys.setrecursionlimit(10**6)

def dfs(G,v,p,color):

    cnt=1

    for nv in G[v]:

        if(nv==p):

            continue

        if cnt in liset[v]:

            while(cnt in liset[v]):

                cnt+=1

        liset[v].add(cnt)

        liset[nv].add(cnt)

        dic[str(v)+'t'+str(nv)]=cnt

        dfs(G,nv,v,cnt)

N=int(eval(input()))

G=[[] for i in range(N)]

e=[]

for i in range(N-1):

    a,b=[int(x)-1 for x in input().split()]

    G[a].append(b)

    G[b].append(a)

    e.append([a,b])

l=0

for i in range(N):

    l=max(l,len(G[i]))

liset=[set() for i in range(N)]

dic={}

dfs(G,0,-1,0)

print(l)

for i in range(N-1):

    if str(e[i][0])+'t'+str(e[i][1]) in dic:

        print((dic[str(e[i][0])+'t'+str(e[i][1])]))

    else:

        print((dic[str(e[i][1])+'t'+str(e[i][0])]))
import sys

sys.setrecursionlimit(10**6)

def dfs(G,v,p,color):

    cnt=1

    for nv in G[v]:

        if(nv==p):

            continue

        while(cnt in s[v]):

                cnt+=1

        s[v].add(cnt)

        s[nv].add(cnt)

        dic[tuple(sorted([v,nv]))]=cnt

        dfs(G,nv,v,cnt)

        

N=int(eval(input()))

G=[[] for i in range(N)]

e=[]

s=[set() for i in range(N)]

dic={}

for i in range(N-1):

    a,b=[int(x)-1 for x in input().split()]

    G[a].append(b)

    G[b].append(a)

    e.append(sorted([a,b]))

l=0

for i in range(N):

    l=max(l,len(G[i]))

dfs(G,0,-1,0)

print(l)

for i in range(N-1):

    print((dic[e[i][0],e[i][1]]))
import sys

sys.setrecursionlimit(10**6)


def dfs(G, v, p, color):
    cnt = 1
    for nv in G[v]:
        if nv == p:
            continue
        if cnt in liset[v]:
            while cnt in liset[v]:
                cnt += 1
        liset[v].add(cnt)
        liset[nv].add(cnt)
        dic[str(v) + "t" + str(nv)] = cnt
        dfs(G, nv, v, cnt)


N = int(eval(input()))
G = [[] for i in range(N)]
e = []
for i in range(N - 1):
    a, b = [int(x) - 1 for x in input().split()]
    G[a].append(b)
    G[b].append(a)
    e.append([a, b])
l = 0
for i in range(N):
    l = max(l, len(G[i]))
liset = [set() for i in range(N)]
dic = {}
dfs(G, 0, -1, 0)
print(l)
for i in range(N - 1):
    if str(e[i][0]) + "t" + str(e[i][1]) in dic:
        print((dic[str(e[i][0]) + "t" + str(e[i][1])]))
    else:
        print((dic[str(e[i][1]) + "t" + str(e[i][0])]))

import sys

sys.setrecursionlimit(10**6)


def dfs(G, v, p, color):
    cnt = 1
    for nv in G[v]:
        if nv == p:
            continue
        while cnt in s[v]:
            cnt += 1
        s[v].add(cnt)
        s[nv].add(cnt)
        dic[tuple(sorted([v, nv]))] = cnt
        dfs(G, nv, v, cnt)


N = int(eval(input()))
G = [[] for i in range(N)]
e = []
s = [set() for i in range(N)]
dic = {}
for i in range(N - 1):
    a, b = [int(x) - 1 for x in input().split()]
    G[a].append(b)
    G[b].append(a)
    e.append(sorted([a, b]))
l = 0
for i in range(N):
    l = max(l, len(G[i]))
dfs(G, 0, -1, 0)
print(l)
for i in range(N - 1):
    print((dic[e[i][0], e[i][1]]))

-        if cnt in liset[v]: -            while cnt in liset[v]: -                cnt += 1 -        liset[v].add(cnt) -        liset[nv].add(cnt) -        dic[str(v) + "t" + str(nv)] = cnt +        while cnt in s[v]: +            cnt += 1 +        s[v].add(cnt) +        s[nv].add(cnt) +        dic[tuple(sorted([v, nv]))] = cnt +s = [set() for i in range(N)] +dic = {} -    e.append([a, b]) +    e.append(sorted([a, b])) -liset = [set() for i in range(N)] -dic = {} -    if str(e[i][0]) + "t" + str(e[i][1]) in dic: -        print((dic[str(e[i][0]) + "t" + str(e[i][1])])) -    else: -        print((dic[str(e[i][1]) + "t" + str(e[i][0])])) +    print((dic[e[i][0], e[i][1]]))