Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
b=[0]*(n-1)
def f(x,y):
    r=1
    for (i,j) in a[x]:
        if r==y:
            r+=1
        b[j]=r
        f(i,r)
        r+=1
f(0,0)
print(max(b))
print(*b,sep="\n")

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
b=[0]*(n-1)
def f(x,y):
    r=1
    for (i,j) in a[x]:
        if r==y:
            r+=1
        b[j]=r
        f(i,r)
        r+=1
f(0,0)
print(max(b))
print(*ans,sep="\n")

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
b=[0]*(n-1)
def f(x,y):
    r=1
    for (i,j) in a[x]:
        if r==y:
            r+=1
        b[j]=r
        f(i,r)
        r+=1
f(0,0)
print(max(b))
for i in b:
    print(i)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
c=[None]*(n-1)
def f(x,y):
    r=1
    for i in a[x]:
        if r==y:
            r+=1
        c[i[1]]=r
        f(i[0],r)
        r+=1
f(0,0)
print(max(c))
for i in c:
    print(i)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
c=[0]*(n-1)
def f(x,y):
    r=1
    for i in a[x]:
        if r==y:
            r+=1
        c[i[1]]=r
        f(i[0],r)
        r+=1
f(0,0)
print(max(c))
for i in c:
    print(i)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c-1].append([d-1,i])
c=[0]*(n-1)
def f(x,y):
    r=1
    for i in a[x]:
        if r==y:
            r+=1
        c[i[1]]=r
        f(i[0],r)
        r+=1
f(1,0)
print(max(c))
for i in c:
    print(i)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[[]for i in range(n+1)]
for i in range(n-1):
    c,d=map(int,input().split())
    a[c].append([d,i])
c=[0]*(n-1)
def f(x,y):
    r=1
    for i in a[x]:
        if r==y:
            r+=1
        c[i[1]]=r
        f(i[0],r)
        r+=1
f(1,0)
print(max(c))
for i in c:
    print(i)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
s=[[]for i in range(n+1)]
t=[0]*(n-1)
for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append([b-1,i])
def f(x,r):
    c=1
    for (i,j) in s[x]:
        if c==r:
            c+=1
        t[j]=c
        f(i,c)
        c+=1
f(0,0)
print(max(t))
for i in t:
    print(i)