qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
def main():
    n=int(input())
    s=input()
    sum=''
    model='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
    m=list(model)
    for i in range(len(s)):
        now=m.index(s[i])
        sum=sum+m[now+n]
    print(sum)


if __name__=='__main__':
    main()   def main():
    

# Fixed code:
def main():
    n=int(input())
    s=input()
    sum=''
    model='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
    m=list(model)
    for i in range(len(s)):
        now=m.index(s[i])
        sum=sum+m[now+n]
    print(sum)


if __name__=='__main__':
    main()
# Buggy code:
N = int(input())
S = input()
A = ''
for i in range(len(S)):
    if ord(S[i])+N <= 90:
        A += chr(ord(S[i])+N)
        print(A)
    else:
        A += chr(ord(S[i])+N-26)
        print(A)
print(A)

# Fixed code:
N = int(input())
S = input()
A = ''
for i in range(len(S)):
    if ord(S[i])+N <= 90:
        A += chr(ord(S[i])+N)
    
    else:
        A += chr(ord(S[i])+N-26)
        
print(A)
# Buggy code:
a = input().splitlines()

N = int(a[0])
S = a[1]

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)

# Fixed code:
a = input()
b = input()

N = int(a)
S = b

alpha_dict = {chr(c): i+1 for i, c in enumerate(range(ord('A'), ord('Z')+1))}

st =""

for c in S:
    n = alpha_dict[c]
    n = n + N
    if (n > 26):
        n = n - 26
    keys = [k for k, v in alpha_dict.items() if v == n]
    st += str(keys[0])
    
print(st)
# Buggy code:
# -*- coding: utf-8 -*-

print(chr(65))
def solve():
    N = int(input())
    S = input()
    d = {chr(65+s):chr(65+(s+N)%26) for s in range(26)}
    table = str.maketrans(d)
    res = S.translate(table)
    return res
    



if __name__ == '__main__':
    print(solve())


# Fixed code:
# -*- coding: utf-8 -*-

def solve():
    N = int(input())
    S = input()
    d = {chr(65+s):chr(65+(s+N)%26) for s in range(26)}
    table = str.maketrans(d)
    res = S.translate(table)
    return res

if __name__ == '__main__':
    print(solve())
# Buggy code:
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

S = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'*2

sn = ""

for i in s:
    sn += S[S.index(i)+2]

print(sn)

# Fixed code:
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

S = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'*2

sn = ""

for i in s:
    sn += S[S.index(i)+n]

print(sn)
# Buggy code:

num = input()
s = input()
res = ""
for x in s:
    loc = ord(x) + num
    res += chr(loc - 26 if loc > 90 else loc)
print(res)

# Fixed code:
num = int(input())
s = input()
res = ""
for x in s:
    loc = ord(x) + num
    res += chr(loc - 26 if loc > 90 else loc)
print(res)
# Buggy code:
N = int(input())
S = input()
codePoint = []

splitedInput = list(S)
wordCount = len(splitedInput)
for i in range(wordCount):
    convertAscii = ord(splitedInput[i]) + N
    if convertAscii > ord("Z"):
        convertAscii = convertAscii - ord("Z") + ord("A") - 1
    conversion = chr(convertAscii)
    codePoint.append(conversion)

print(codePoint)

# Fixed code:
N = int(input())
S = input()
codePoint = []

splitedInput = list(S)
wordCount = len(splitedInput)
for i in range(wordCount):
    convertAscii = ord(splitedInput[i]) + N
    if convertAscii > ord("Z"):
        convertAscii = convertAscii - ord("Z") + ord("A") - 1
    conversion = chr(convertAscii)
    codePoint.append(conversion)

ans = "".join(codePoint)
print(ans)
# Buggy code:
N=int(input)
S=list(input())

ans=[]
for i in S:
    if ord(i)+N>90:
        temp=chr(ord(i)+N-26)
        ans.append(temp)
    else:
        temp=chr(ord(i)+N)
        ans.append(temp)

f=''.join(ans)

print(f)

# Fixed code:
N=int(input())
S=list(input())
 
ans=[]
for i in S:
    if ord(i)+N>90:
        temp=chr(ord(i)+N-26)
        ans.append(temp)
    else:
        temp=chr(ord(i)+N)
        ans.append(temp)
 
f=''.join(ans)
 
print(f)
# Buggy code:
n=int(input())
s=str(input())
l=list(s)
t=len(s)

for i in range(t):
    if ord(l[i])+2<65+26:
        l[i]=chr(ord(l[i])+2)
    else:
        l[i]=chr(ord(l[i])+2-26)
ans="".join(l)
print(ans)


# Fixed code:
n=int(input())
s=str(input())
l=list(s)
t=len(s)

for i in range(t):
    if ord(l[i])+n<65+26:
        l[i]=chr(ord(l[i])+n)
    else:
        l[i]=chr(ord(l[i])+n-26)
ans="".join(l)
print(ans)
# Buggy code:
N = int(input())
S = input()
alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def get_str_leading_n(string, alphabets, N):
    index_ = (alphabets.index(string.upper()) + N) // 26
    return alphabets[index_]
output = "".join(list(map(lambda p: get_str_leading_n(p, alphabets, N), S)))
print(output)

# Fixed code:
N = int(input())
S = input()
alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def get_str_leading_n(string, alphabets, N):
    index_ = (alphabets.index(string.upper()) + N) % 26
    return alphabets[index_]
output = "".join(list(map(lambda p: get_str_leading_n(p, alphabets, N), S)))
print(output)
# Buggy code:
# B - ROT N
# https://atcoder.jp/contests/abc146/tasks/abc146_b

N = int(input())
S = input()

tmp = ""

for s in S:
    unicode_point = ord(s) + N

    if unicode_point >= 90:
        unicode_point = 65 + (unicode_point - 90)

    tmp += chr(unicode_point)

print(tmp)

# Fixed code:
# B - ROT N
# https://atcoder.jp/contests/abc146/tasks/abc146_b

N = int(input())
S = input()

tmp = ""

for s in S:
    unicode_point = ord(s) + N

    if unicode_point > 90:
        unicode_point = 64 + (unicode_point - 90)

    tmp += chr(unicode_point)

print(tmp)
# Buggy code:
N=int(input())
S=input()
ans=""
for s in S:
  if ord("Z") < ord(s)+N:
    ans+=chr(ord("A")+ord("Z")-(ord(s)+N))
  else:
    ans+=chr(ord(s)+N)
print(ans)

# Fixed code:
N=int(input())
S=input()
ans=""
for s in S:
  if ord("Z") < ord(s)+N:
    ans+=chr(ord("A")+ord(s)+N-ord("Z")-1)
  else:
    ans+=chr(ord(s)+N)
print(ans)
# Buggy code:
n=input()

s=input()
s=s.lower()

list=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
length=len(s)
print(length)
export=""
for i in range(length):
    num=list.index(s[i])
    num=(num+int(n))%26
    export+=list[num]
    
export=export.upper()
print(export)


# Fixed code:
n=input()

s=input()
s=s.lower()

list=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
length=len(s)
export=""
for i in range(length):
    num=list.index(s[i])
    num=(num+int(n))%26
    export+=list[num]
    
export=export.upper()
print(export)
# Buggy code:
N=int(input())
S=input()
ANS=""
for i in range(len(S)):
    ANS+=chr(64+((ord(S[i])+N)-64)%26)
print(ANS)

# Fixed code:
N=int(input())
S=input()
ANS=""
for i in range(len(S)):
    ANS+=chr(65+((ord(S[i])+N)-65)%26)
print(ANS)
# Buggy code:
n = int(input())
s = input()
for i in s:
    if ord(i) + n > 90:
        print(chr(64+n-(90-ord(i))))
    else:    
        print(chr(ord(i)+n))

# Fixed code:
n = int(input())
s = input()
out = ""
for i in s:
    if ord(i) + n > 90:
        out += chr(64+n-(90-ord(i)))
    else:    
        out += chr(ord(i)+n)

print(out)
# Buggy code:
n=int(input())
s=input()

t=[]
for i in range(len(s)):
  num=ord(s[i])+n
  if num>122:
    num-=26
  t.append(chr(num))

print("".join(t))

# Fixed code:
n=int(input())
s=input()
 
t=[]
for i in range(len(s)):
  num=ord(s[i])+n
  if num>90:
    num-=26
  t.append(chr(num))

print("".join(t))
# Buggy code:
N = int(input())
S = input()
for i in S:
	m = (ord(i) - ord('A') + N) % 26
    ans += chr(m +ord('A'))
print(ans)

# Fixed code:
N = int(input())
S = input()
ans = str()
for i in S:
	m = (ord(i) - ord('A') + N) % 26
	ans += chr(m + ord('A'))
print(ans)
# Buggy code:
a = ["A","B","C","D","E","F","G",
    "H","I","J","K","L","M","N",
    "O","P","Q","R","S","T","U",
    "V","W","X","Y","Z"]
N = int(input())
S = input()
for s in S:
  print(a.index(s))


# Fixed code:
a = ["A","B","C","D","E","F","G",
    "H","I","J","K","L","M","N",
    "O","P","Q","R","S","T","U",
    "V","W","X","Y","Z"]
N = int(input())
S = input()
o = ""
for s in S:
  o += a[(a.index(s)+N)%26]

print(o)
# Buggy code:
N = int(input())
S = input()
Answer_list = []

for i in list(S):
    num = ord(i)+N
    if num >= 65 || num =< 90:
        Answer_list.append(chr(num))
    elif num < 90:
        Answer_list.append(chr(num - 26)        
print(''.join(Answer_list))

# Fixed code:
N = int(input())
S = input()
Answer_list = []
for i in list(S):
    num = ord(i)+N
    if num >= 65 and num <= 90:
        Answer_list.append(chr(num))
    elif num > 90:
        Answer_list.append(chr(num - 26))
print(''.join(Answer_list))
# Buggy code:
n = int(input())
s = input()
ans = ''
for i in s:
  ans += chr((ord(i)+n-1 - ord('A'))%26 + 1 + ord('A'))
print(ans)


# Fixed code:
n = int(input())
s = input()
ans = ''
for i in s:
  ans += chr((ord(i)-ord('A')+n)%26 + ord('A'))
print(ans)
# Buggy code:
n = int(input())
inp_string = input()
result = ""
for char in inp_string:
  value = ord(char)
  value += n
  print(char,value)
  if value > 90:
    value = 64 + (value - 90)
  print(value,chr(value))
  result += chr(value)
print(result)

# Fixed code:
n = int(input())
inp_string = input()
result = ""
for char in inp_string:
  value = ord(char)
  value += n
  if value > 90:
    value = 64 + (value - 90)
  result += chr(value)
print(result)
# Buggy code:
n = int(input())
s = list(input())

alp = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

print(alp.index('F'))

for i in range(len(s)):
    s[i] = alp[(int(alp.index(s[i])) + n) % len(alp)]

print(''.join(s))

# Fixed code:
n = int(input())
s = list(input())
'''
alp = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(len(s)):
    s[i] = alp[(int(alp.index(s[i])) + n) % len(alp)]

print(''.join(s))
'''

for i in range(len(s)):
    s[i] = chr((ord(s[i]) + n - 65)%26 +65)

print(''.join(s))
# Buggy code:
n=int(input())
s=input()
num=len(s)
new=""
for i in range(num):
  a=ord(s[i])
  b=a+n
  if b>90:
    new+=chr(b-24)
  else:
    new+=chr(b)
print(new)

# Fixed code:
n=int(input())
s=input()
num=len(s)
new=""
for i in range(num):
  a=ord(s[i])
  b=a+n
  if b>90:
    new+=chr(b-26)
  else:
    new+=chr(b)
print(new)
# Buggy code:
n=int(input())
S=input()

def forward(s, n):
  A_id = ord('A')
  num_AtoZ = ord('Z') - ord('A') + 1
  return chr(A_id + (ord(s) + n) % (A_id + num_AtoZ))

print(''.join([forward(s, n) for s in S]))


# Fixed code:
n=int(input())
S=input()

def forward(s, n):
  A_id = ord('A')
  num_AtoZ = ord('Z') - ord('A') + 1
  return chr(A_id + (ord(s) - A_id + n) % (num_AtoZ))

print(''.join([forward(s, n) for s in S]))
# Buggy code:
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    s = input()
    first = ord("A") - 1
    last = ord("Z")
    increment = lambda x: chr(ord(x)+n) if ord(x)+n <= last else chr(first + (ord(x)+n - last))
    new_s = "".join(map(increment, s))
    print(new_s)
    


if __name__ == '__main__':
    main()


# Fixed code:
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    s = input().rstrip()
    first = ord("A") - 1
    last = ord("Z")
    increment = lambda x: chr(ord(x)+n) if ord(x)+n <= last else chr(first + (ord(x)+n - last))
    new_s = "".join(map(increment, s))
    print(new_s, end="")
    


if __name__ == '__main__':
    main()
# Buggy code:
N = int(input())
S = input()

alphabet = "ABCDEFGHIJKLMNOPQUSTUVWXYZ"

newS = S.translate(str.maketrans(alphabet, alphabet[N:]+alphabet[:N]))
print(newS)

# Fixed code:
N = int(input())
S = input()

alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

newS = S.translate(str.maketrans(alphabet, alphabet[N:]+alphabet[:N]))
print(newS)
# Buggy code:
a = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
S = input()
N = int(input())

for i in S:
  b = a.index(i) + N
  if b<=25:
    print(a[b], end="")
  else:
    print(a[b-25], end="")


# Fixed code:
a = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
N = int(input())
S = input()
 
for i in S:
    b = a.index(i) + N
    if b <= 25:
        print(a[b], end="")
    else:
        print(a[b-26], end="")
# Buggy code:
import sys
from collections import deque
read = sys.stdin.read

N, *ab = map(int, read().split())
graph = [[] for _ in range(N + 1)]

for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)

color = [0] * (N + 1)
queue = deque([1])
color_v = [0] * (N + 1)

while queue:
    V = queue.popleft()
    number = 1
    for v in graph[V]:
        if number == color_v[V]:
            number += 1
        color[v] = number
        queue.append(v)
        number += 1

print(max(color))
for a, b in zip(*[iter(ab)] * 2):
    print(color[b])

# Fixed code:
import sys
from collections import deque
read = sys.stdin.read

N, *ab = map(int, read().split())
graph = [[] for _ in range(N + 1)]

for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)

color = [0] * (N + 1)
queue = deque([1])
color_v = [set() for _ in range(N + 1)]

while queue:
    V = queue.popleft()
    number = 1
    for v in graph[V]:
        if number in color_v[V]:
            number += 1
        color[v] = number
        color_v[V].add(number)
        color_v[v].add(number)
        queue.append(v)
        number += 1

print(max(color))
for a, b in zip(*[iter(ab)] * 2):
    print(color[b])
# Buggy code:
import sys
from collections import deque

def main():
    n = int(sys.stdin.readline().rstrip())
    ab = map(int, sys.stdin.read().split())
    ab = list(zip(ab, ab))

    G = [[] for _ in range(n + 1)]
    for a, b in ab:
        G[a].append(b)
        G[b].append(a)
    
    q = deque([1]) # root = 1
    parent = [None] * (n + 1)
    color = [0] * (n + 1) # color of the edge(parent[y], y)

    while q:
        x = q.popleft()
        ng = color[x]
        c = 1
        for y in G[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            if c == ng:
                c += 1
            color[y] = c
            q.append(y)
            c += 1
            
    k = max(color)

    for a, b in ab:
        if a == parent[b]:
            print(color[b])
        else:
            print(color[a])

if __name__ == '__main__':
    main()

# Fixed code:
import sys
from collections import deque

def main():
    n = int(sys.stdin.readline().rstrip())
    ab = map(int, sys.stdin.read().split())
    ab = list(zip(ab, ab))

    G = [[] for _ in range(n + 1)]
    for a, b in ab:
        G[a].append(b)
        G[b].append(a)
    
    q = deque([1]) # root = 1
    parent = [None] * (n + 1)
    color = [0] * (n + 1) # color of the edge(parent[y], y)

    while q:
        x = q.popleft()
        ng = color[x]
        c = 1
        for y in G[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            if c == ng:
                c += 1
            color[y] = c
            q.append(y)
            c += 1
            
    print(max(color))

    for a, b in ab:
        if a == parent[b]:
            print(color[b])
        else:
            print(color[a])

if __name__ == '__main__':
    main()
# Buggy code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    from collections import defaultdict
    num_c = defaultdict(int)
    E = defaultdict(lambda:defaultdict(int))
    inputE = []
    for i in range(N-1):
        ai,bi = LMIIS()
        if bi < ai:
            ai,bi = bi,ai
        num_c[ai] += 1
        num_c[bi] += 1
        E[ai][bi]= -1
        inputE.append((ai,bi))
    max_c = max(num_c.values())
    


    def colour(e1,e2,c):
        E[e1][e2] = c
        tmpc = 0
        for e22 in E[e2].keys():
            tmpc += 1
            if tmpc == c:
                tmpc +=  1
            colour(e2,e22,tmpc)

            
        pass

    colour(1,2,1)
    print(max_c)


    for ai,bi in inputE:
        print(E[ai][bi])



if __name__ == '__main__':
    main()

# Fixed code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    from collections import defaultdict
    num_c = defaultdict(int)
    E = defaultdict(lambda:defaultdict(int))
    inputE = []
    for i in range(N-1):
        ai,bi = LMIIS()
        if bi < ai:
            ai,bi = bi,ai
        num_c[ai] += 1
        num_c[bi] += 1
        E[ai][bi]= -1
        inputE.append((ai,bi))
    max_c = max(num_c.values())
    


    def colour(e1,c):
        tmpc = 0
        for e2 in E[e1].keys():
            tmpc += 1
            if tmpc == c:
                tmpc += 1
            E[e1][e2] = tmpc
            colour(e2,tmpc)

            
        pass
    
    colour(1,0)
    # print(E)
    print(max_c)


    for ai,bi in inputE:
        if E[ai][bi] != -1:
            print(E[ai][bi])



if __name__ == '__main__':
    main()
# Buggy code:
from collections import deque
import sys
sys.setrecursionlimit(20000000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N-1)]
routes = [[] for _ in range(N)]

for i in range(len(ab)):
    routes[ab[i][0]-1].append([ab[i][1]-1, i])
    routes[ab[i][1]-1].append([ab[i][0]-1, i])

route_color = [-10e+10 for _ in range(len(ab))]

route_num = [0]*N
max_route = 0
for i in range(N):
    num = len(routes[i])
    route_num[i] = num
    if max_route < num:
        max_route = num

seen = [False for _ in range(N)]

def function(num):
    color_num = 0
    for route in routes[num]:
        if route_color[route[1]] != -10e+10:
            color_num+=1
        else:
            route_color[route[1]] = color_num
            color_num+=1
        if seen[route[0]] == False:
            seen[route[0]] = True
            function(route[0])
    return

function(0)
print(max_route)
for color in route_color:
    print(color+1)

# Fixed code:
from collections import deque
import sys
sys.setrecursionlimit(20000000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N-1)]
routes = [[] for _ in range(N)]

for i in range(len(ab)):
    routes[ab[i][0]-1].append([ab[i][1]-1, i])
    routes[ab[i][1]-1].append([ab[i][0]-1, i])

route_color = [-10e+10 for _ in range(len(ab))]

route_num = [0]*N
max_route = 0
for i in range(N):
    num = len(routes[i])
    route_num[i] = num
    if max_route < num:
        max_route = num

seen = [False for _ in range(N)]

def function(num,pre_color):
    color_num = -1
    for route in routes[num]:
        color_num += 1
        if color_num == pre_color:
            color_num+=1
        if route_color[route[1]] != -10e+10:
            color_num-=1
            pass
        else:
            route_color[route[1]] = color_num
            
        if seen[route[0]] == False:
            seen[route[0]] = True
            function(route[0],route_color[route[1]])
    return

function(0,-1)
print(max_route)
for color in route_color:
    print(color+1)
# Buggy code:
from collections import deque

def main():
    N = int(input())
    # path = [[] for _ in range(N)]
    path = [[] for _ in range(N-1)]
    ab = []
    ans = {}
    visited = [False] * N
    visited[0] = True
    for _ in range(N-1):
        a, b = map(int, input().split())
        path[a-1].append(b-1)
        # path[b-1].append(a-1)
        ab.append((a-1, b-1))
    
    que = deque([(0, 0)])
    while que:
        k = 1
        pre, c = que.popleft()
        for next_node in path[pre]:
            if visited[next_node]:
                continue
            
            if c == k:
                k += 1
            visited[next_node] = True
            ans[(pre, next_node)] = k
            que.append((next_node, k))
            k += 1
            

    print(max(ans.values()))
    for key in ab:
        print(ans[key])

if __name__ == '__main__':
    main()

# Fixed code:
from collections import deque

def main():
    N = int(input())
    path = [[] for _ in range(N)]
    ab = []
    ans = {}
    visited = [False] * N
    visited[0] = True
    for _ in range(N-1):
        a, b = map(int, input().split())
        path[a-1].append(b-1)
        path[b-1].append(a-1)
        # ab.append(str(a-1)+str(b-1))
        ab.append((a-1, b-1))
    
    que = deque([(0, 0)])
    while que:
        # k = 1
        k = 0
        pre, c = que.popleft()
        for next_node in path[pre]:
            if visited[next_node]:
                continue
            k += 1
            if c == k:
                k += 1
            visited[next_node] = True
            # ans[str(pre)+str(next_node)] = k
            ans[(pre, next_node)] = k
            que.append((next_node, k))
            

    print(max(ans.values()))
    for key in ab:
        print(ans[key])

if __name__ == '__main__':
    main()
# Buggy code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n-1)]

    adj = [[] for _ in range(n)]
    order = []
    for a,b in ab:
        adj[a-1].append(b-1)
        order.append(b-1)

    k = 0
    for i in adj:
        k = max(k, len(i))
    print(k)

    c = [0]*n
    d = deque([0])
    while d:
        v = d.popleft()
        cnt = 1
        for nv in adj[v]:
            if c[v] == cnt:
                cnt += 1
            c[nv] = cnt
            cnt += 1
            d.append(nv)

    for i in order:
        print(c[i])

if __name__ == '__main__':
    main()

# Fixed code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n-1)]

    adj = [[] for _ in range(n)]
    order = []
    for a,b in ab:
        adj[a-1].append(b-1)
        order.append(b-1)

    

    c = [0]*n
    d = deque([0])
    while d:
        v = d.popleft()
        cnt = 1
        for nv in adj[v]:
            if c[v] == cnt:
                cnt += 1
            c[nv] = cnt
            cnt += 1
            d.append(nv)

    print(max(c))

    for i in order:
        print(c[i])

if __name__ == '__main__':
    main()