import sys

sys.setrecursionlimit(200000)

N = int(eval(input()))

ans = [0] * (N - 1)

AB = []

for i in range(N-1):

    a,b = list(map(int,input().split()))

    AB.append([a-1,b-1])

G = [list() for _ in range(N)]

for i in range(N-1):

    G[AB[i][1]].append([AB[i][0],i])

    G[AB[i][0]].append([AB[i][1],i])



def dfs(v,c = -1,p = -1):

    k = 1

    for i in range(len(G[v])):

        u = G[v][i][0];ei = G[v][i][1]

        if u == p:continue

        if k == c:

            k += 1

        ans[ei] = k

        k += 1

        dfs(u,ans[ei],v)

dfs(0)

mx = 0

for i in range(N):

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

print(mx)

for i in range(N-1):

    print((ans[i]))
import sys

sys.setrecursionlimit(200000)

N = int(eval(input()))

ans = [0] * (N - 1)

G = [list() for _ in range(N)]



for i in range(N-1):

    a,b = list(map(int,input().split()))

    a -= 1

    b -= 1

    G[a].append([b,i])

    G[b].append([a,i])



def dfs(v,c = -1,p = -1):

    k = 1

    for i in range(len(G[v])):

        u = G[v][i][0];ei = G[v][i][1]

        if u == p:continue

        if k == c:

            k += 1

        ans[ei] = k

        k += 1

        dfs(u,ans[ei],v)



dfs(0)

mx = 0



for i in range(N):

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

print(mx)



for i in range(N-1):

    print((ans[i]))
import sys

sys.setrecursionlimit(200000)
N = int(eval(input()))
ans = [0] * (N - 1)
AB = []
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    AB.append([a - 1, b - 1])
G = [list() for _ in range(N)]
for i in range(N - 1):
    G[AB[i][1]].append([AB[i][0], i])
    G[AB[i][0]].append([AB[i][1], i])


def dfs(v, c=-1, p=-1):
    k = 1
    for i in range(len(G[v])):
        u = G[v][i][0]
        ei = G[v][i][1]
        if u == p:
            continue
        if k == c:
            k += 1
        ans[ei] = k
        k += 1
        dfs(u, ans[ei], v)


dfs(0)
mx = 0
for i in range(N):
    mx = max(mx, len(G[i]))
print(mx)
for i in range(N - 1):
    print((ans[i]))

import sys

sys.setrecursionlimit(200000)
N = int(eval(input()))
ans = [0] * (N - 1)
G = [list() for _ in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    G[a].append([b, i])
    G[b].append([a, i])


def dfs(v, c=-1, p=-1):
    k = 1
    for i in range(len(G[v])):
        u = G[v][i][0]
        ei = G[v][i][1]
        if u == p:
            continue
        if k == c:
            k += 1
        ans[ei] = k
        k += 1
        dfs(u, ans[ei], v)


dfs(0)
mx = 0
for i in range(N):
    mx = max(mx, len(G[i]))
print(mx)
for i in range(N - 1):
    print((ans[i]))

-AB = [] +G = [list() for _ in range(N)] -    AB.append([a - 1, b - 1]) -G = [list() for _ in range(N)] -for i in range(N - 1): -    G[AB[i][1]].append([AB[i][0], i]) -    G[AB[i][0]].append([AB[i][1], i]) +    a -= 1 +    b -= 1 +    G[a].append([b, i]) +    G[b].append([a, i])