import sys

n=int(eval(input()))

g=[[] for _ in range(n)]

for i in range(n-1):

  a,b=list(map(int,sys.stdin.readline().split()))

  g[a-1].append([b-1,i])

  g[b-1].append([a-1,i])

print((max(len(v) for v in g)))

from collections import deque

l=[0]*(n-1)

q=deque([0])

b=[1]+[0]*(n-1)

while q:

  v=q.pop()

  c=-1

  k=1

  for u,e in g[v]:

    if b[u]: c=l[e]

  for u,e in g[v]:

    if b[u]: continue

    if k==c: k+=1

    l[e]=k

    k+=1

    q.appendleft(u)

    b[u]=1

for c in l: print(c)
import sys

sys.setrecursionlimit(10**6)

n=int(eval(input()))

g=[[] for _ in range(n)]

for i in range(n-1):

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

  g[a-1]+=[(b-1,i)]

  g[b-1]+=[(a-1,i)]

l=[0]*(n-1)

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

  t=1

  for c,i in g[v]:

    if c==p: continue

    if t==s: t+=1

    l[i]=t

    dfs(c,v,t)

    t+=1

dfs(0)

print((max(l)))

for i in l: print(i)
import sys

n = int(eval(input()))
g = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = list(map(int, sys.stdin.readline().split()))
    g[a - 1].append([b - 1, i])
    g[b - 1].append([a - 1, i])
print((max(len(v) for v in g)))
from collections import deque

l = [0] * (n - 1)
q = deque([0])
b = [1] + [0] * (n - 1)
while q:
    v = q.pop()
    c = -1
    k = 1
    for u, e in g[v]:
        if b[u]:
            c = l[e]
    for u, e in g[v]:
        if b[u]:
            continue
        if k == c:
            k += 1
        l[e] = k
        k += 1
        q.appendleft(u)
        b[u] = 1
for c in l:
    print(c)

import sys

sys.setrecursionlimit(10**6)
n = int(eval(input()))
g = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = list(map(int, input().split()))
    g[a - 1] += [(b - 1, i)]
    g[b - 1] += [(a - 1, i)]
l = [0] * (n - 1)


def dfs(v, p=-1, s=-1):
    t = 1
    for c, i in g[v]:
        if c == p:
            continue
        if t == s:
            t += 1
        l[i] = t
        dfs(c, v, t)
        t += 1


dfs(0)
print((max(l)))
for i in l:
    print(i)

+sys.setrecursionlimit(10**6) -    a, b = list(map(int, sys.stdin.readline().split())) -    g[a - 1].append([b - 1, i]) -    g[b - 1].append([a - 1, i]) -print((max(len(v) for v in g))) -from collections import deque +    a, b = list(map(int, input().split())) +    g[a - 1] += [(b - 1, i)] +    g[b - 1] += [(a - 1, i)] +l = [0] * (n - 1) -l = [0] * (n - 1) -q = deque([0]) -b = [1] + [0] * (n - 1) -while q: -    v = q.pop() -    c = -1 -    k = 1 -    for u, e in g[v]: -        if b[u]: -            c = l[e] -    for u, e in g[v]: -        if b[u]: + +def dfs(v, p=-1, s=-1): +    t = 1 +    for c, i in g[v]: +        if c == p: -        if k == c: -            k += 1 -        l[e] = k -        k += 1 -        q.appendleft(u) -        b[u] = 1 -for c in l: -    print(c) +        if t == s: +            t += 1 +        l[i] = t +        dfs(c, v, t) +        t += 1 + + +dfs(0) +print((max(l))) +for i in l: +    print(i)