Harryxun/stf_run huggingface dataset:
n=int(raw_input())
a=[int(raw_input()) for _ in xrange(n)]
mxlba=0
for i in xrange(n):
    mxlba=max(mxlba,len(bin(a[i])[2:]))
cnt=[0]*(mxlba+5)
for i in xrange(n):
    bit=bin(a[i])[2:]
    lb=len(bit)
    for j in xrange(lb-1,-1,-1):
        if bit[j]=="1":
            cnt[lb-1-j]+=1
            break

axor=0
for i in xrange(n):
    axor^=a[i]

axor=bin(axor)[2:]
la=len(axor)
ans=0
i=-1
while i<la:
    i+=1
    if axor[i]=="1":
        if cnt[i]==0:
            print(-1)
            exit()
        else:
            ans+=1
            cnt[i]-=1
            if la-i-1==0:
                break
            tmp=int("1"*(la-i-1),2)
            axor=int(axor,2)^tmp
            axor=bin(axor)[2:]

print(ans)


### FIXED CODE ###

n=int(raw_input())
a=[int(raw_input()) for _ in xrange(n)]
mxlba=0
for i in xrange(n):
    mxlba=max(mxlba,len(bin(a[i])[2:]))

exist=[False]*(mxlba+1000)
for i in xrange(n):
    bit=bin(a[i])[2:]
    lb=len(bit)
    for j in xrange(lb-1,-1,-1):
        if bit[j]=="1":
            exist[lb-1-j]=True
            break

axor=0
for i in xrange(n):
    axor^=a[i]
if axor==0:
    print(0)
    exit()
axor=bin(axor)[2:]
la=len(axor)
ans=0
i=0
while i<la:
    if axor[i]=="1":
        if not exist[la-i-1]:
            print(-1)
            exit()
        else:
            ans+=1
            if la-i-1==0:
                break
            tmp=int("1"*(la-i-1),2)
            axor=int(axor,2)^tmp
            axor=bin(axor)[2:]
    i+=1

print(ans)
import sys

sys.setrecursionlimit(8000)


H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())

def rec(h,w):
    seen[h][w]=1
    step=[[0,1],[0,-1],[1,0],[-1,0]]
    ret=0
    for dh,dw in step:
        nh=h+dh
        nw=w+dw
        if 0<=nh<H and 0<=nw<W:
            if seen[nh][nw]==0 and S[nh][nw]==".":
                ret+=1
                seen[nh][nw]=1
                for ddh,ddw in step:
                    if 0<=nh + ddh<H and 0<=nw + ddw < W:
                        if seen[nh+ddh][nw+ddw]==0 and S[nh+ddh][nw+ddw]=="#":
                            ret+=rec(nh+ddh,nw+ddw)
    return ret


ans=0
for h in range(H):
    for w in range(W):
        seen=[[0]*W for _ in range(H)]
        if S[h][w]=="#":
            ans+=rec(h,w)

print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)


H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())

def DFS(h,w,black,white,m):
    black,white=BorW(h,w,black,white)
    step=[[0,1],[0,-1],[1,0],[-1,0]]
    seen[h][w]=1
    for dh,dw in step:
        nh=h+dh
        nw=w+dw
        if 0<=nh<H and 0<=nw<W:
            if seen[nh][nw]==0 and m!=S[nh][nw]:
                seen[nh][nw]=1
                black,white=DFS(nh,nw,black,white,S[nh][nw])
    return black,white


def BorW(h,w,black,white):
    if S[h][w]=="#":
        black+=1
    else:
        white+=1
    return black,white


seen=[[0]*W for _ in range(H)]

L=[]
for h in range(H):
    for w in range(W):
        black=0
        white=0
        if seen[h][w]==0:
            black,white=DFS(h,w,black,white,S[h][w])
            L.append([black,white])
ans=0
for b,w in L:
     ans+=b*w

print(ans)
import math
from functools import reduce

n = int(input())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
t = [int(m) for m in d]

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

#print(lcm(27, 18, 9, 3))
# 54

#print(lcm(27, 9, 3))
# 27

#print(lcm(*[27, 9, 3]))
# 27

print(lcm_list(t))


### FIXED CODE ###

from functools import reduce

n = int(input())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
t = [int(m) for m in d]

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

#print(lcm(27, 18, 9, 3))
# 54

#print(lcm(27, 9, 3))
# 27

#print(lcm(*[27, 9, 3]))
# 27

print(lcm_list(t))
def check_right_triangle(side1, side2, side3):
	if side1**2 == side2**2 + side3**2:
		return True
	if side2**2 == side3**2 + side1**2:
		return True
	if sides3**3 == side1**2 + side2**2:
		return True
	return False

for i in range(int(raw_input())):
	sides = map(int, raw_input().split())
	if check_right_triangle(sides[0], sides[1], sides[2]):
		print "YES"
	print "NO"

### FIXED CODE ###

def check_right_triangle(side1, side2, side3):
	pow = 2
	if side1**pow == side2**pow + side3**pow:
		return True
	if side2**pow == side3**pow + side1**pow:
		return True
	if side3**pow == side1**pow + side2**pow:
		return True
	return False


def check():
	for i in range(int(raw_input())):
		sides = map(int, raw_input().split())
		if check_right_triangle(sides[0], sides[1], sides[2]):
			print "YES"
		else:
			print "NO"



if __name__ == "__main__":
	check()
	# print check_right_triangle(4, 3, 5)
	# print check_right_triangle(4, 3, 6)
	# print check_right_triangle(8, 8, 8)
n = int(input())
dic = {}
list = [int(i) for i in input().split()]
for i in list:
    if i not in dic:
        dic[i] = 0
    dic[i] += 1
q = int(input())
ans = sum(list)
for j in range(q):
    b,c = (int(x) for x in input().split())
    if b not in dic:
        pass
    else:
        if c not in dic:
            dic[c] = dic[b]
        else:
            dic[c] += dic[b]
    ans = ans + (c-b)*dic[b]
    dic[b] = 0
    print(ans)

### FIXED CODE ###

n = int(input())
dic = {}
list = [int(i) for i in input().split()]
for i in list:
    if i not in dic:
        dic[i] = 0
    dic[i] += 1
q = int(input())
ans = sum(list)
for j in range(q):
    b,c = (int(x) for x in input().split())
    if b not in dic:
        print(ans)
        continue
    else:
        if c not in dic:
            dic[c] = dic[b]
        else:
            dic[c] += dic[b]
    ans = ans + (c-b)*dic[b]
    dic[b] = 0
    print(ans)
import math

def lcm(a,b):
    return (a*b)//math.gcd(a,b)

n = int(input())
b = [1]*(n+5)
mod = 1e9 + 7
a = [int(i) for i in input().split()]
    
for i in range(n):
    for j in range(i+1,n):
        x = a[i]
        y = a[j]
        m = math.gcd(x,y)
        x //= m
        y //= m
        b[i] = lcm(b[i],y)
        b[j] = lcm(b[j],x)
sum = 0
for i in range(n):
    sum += b[i]
print("%d" %(sum%mod))


### FIXED CODE ###

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
n=int(input())
mod=1000000007
s=[int(i) for i in input().split()]
ans=1
for i in s:
    ans*=i//gcd(ans,i)
print(sum(ans//i for i in s)%mod)
import math
from functools import reduce
def g(n):
    return reduce(math.gcd,n)
n=int(input())
print(g(list(map(int,input().split()))))

### FIXED CODE ###

import fractions
from functools import reduce
def g(n):
    return reduce(fractions.gcd,n)
n=int(input())
print(g(list(map(int,input().split()))))
import sys
h, w = map(int, sys.stdin.readline().split())
dp = [[0] * w for _ in range(h)]
G = [list(map(int, i.split())) for i in sys.stdin.readlines()]
for x in range(h):
    dp[x][0] = 1 if G[x][0] == 0 else 0
for y in range(w):
    dp[0][y] = 1 if G[0][y] == 0 else 0
for i in range(1, h):
    for j in range(1, w):
        if(G[i][j] == 0):
            dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1
print(max(sum(dp, []) ** 2)

### FIXED CODE ###

import sys
import itertools
h, w = map(int, sys.stdin.readline().split())
dp = [[0] * w for _ in range(h)]
G = [[int(j) for j in sys.stdin.readline().split()] for _ in range(h)]
for x in range(h):
    dp[x][0] = 1 if G[x][0] == 0 else 0
for y in range(w):
    dp[0][y] = 1 if G[0][y] == 0 else 0
for i in range(1, h):
    for j in range(1, w):
        if(G[i][j] == 0):
            dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1
print(max(max(i) for i in dp) ** 2)
n, k = map(int, input().split())
hlis = list(map(int, input().split()))
# hlis.sort(reverse=True)

for i in range(0, k):
  cache = max(hlis)
  hlis.remove(cache)
print(sum(hlis))


### FIXED CODE ###

n, k = map(int, input().split())
hlis = list(map(int, input().split()))
hlis.sort(reverse=True)

del hlis[0:k]
print(sum(hlis))
import numpy as np
input()
x = np.array(input().split(), dtype=np.int32)

ans = 0
while ( x % 2 == 0 ).all():
  	x //= 2
	ans += 1
print(ans)    


### FIXED CODE ###

import numpy as np
input()
x = np.array(input().split(),dtype=np.int32)

ans = 0
while (x%2==0).all():
  x //= 2
  ans += 1
print(ans)
import math

k = int(input())
ans = 0

for i in range(1,k+1):
    for j in range(1,k+1):
        a = gcd(i,j)
        for l in range(1,k+1):
            ans += gcd(a,l)

print(ans)

### FIXED CODE ###

import math

k = int(input())
ans = 0

for i in range(1,k+1):
    for j in range(1,k+1):
        a = math.gcd(i,j)
        for l in range(1,k+1):
            ans += math.gcd(a,l)

print(ans)
def zeroTrim(s):
    while s[0] == '0':
        if len(s) == 1:
            break
        s = s[1:]
    return s

N = input()
K = int(input())

def calc(N, K):
    digit = len(N)
    res = 0

    if K == 1:
        if digit > 1:
            res += (digit - 1) * 9
        res += int(N[0])
    elif K == 2:
        if digit > 2:
            res += 9 * 9 * (digit - 1) * (digit - 2) // 2
        for i in range(int(N[0])-1):
            res += calc('9'*(digit-1), 1)
        res += calc(zeroTrim(N[1:]), 1)
    else:
        if digit > 3:
            res += 9 * 9 * 9 * (digit - 1) * (digit - 2) * (digit - 3) // 6
        
        for i in range(int(N[0])-1):
            res += calc('9'*(digit-1), 2)
        res += calc(zeroTrim(N[1:]), 2)
    return res

print(calc(N, K))

### FIXED CODE ###

def zeroTrim(s):
    while s[0] == '0':
        if len(s) == 1:
            break
        s = s[1:]
    return s

N = input()
K = int(input())

def calc(N, K):
    digit = len(N)
    res = 0

    if K == 1:
        if digit > 1:
            res += (digit - 1) * 9
        res += int(N[0])
    elif K == 2:
        if digit <= 1:
            return 0
        if digit > 2:
            res += 9 * 9 * (digit - 1) * (digit - 2) // 2
        for i in range(int(N[0])-1):
            res += calc('9'*(digit-1), 1)
        res += calc(zeroTrim(N[1:]), 1)
    else:
        if digit <= 2:
            return 0
        if digit > 3:
            res += 9 * 9 * 9 * (digit - 1) * (digit - 2) * (digit - 3) // 6
        
        for i in range(int(N[0])-1):
            res += calc('9'*(digit-1), 2)
        res += calc(zeroTrim(N[1:]), 2)
    return res

print(calc(N, K))
def solve():
    A, B, K = map(int, input().split())
    if K <= A:
        print(A-K, B)
    elif A+B <= K:
        print(0, 0)
    else:
        print(0, B-(K-A))


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def solve():
    S, T = map(str, input().split())
    print(T+S)


if __name__ == '__main__':
    solve()
n = input()
array = []
for i in range(n):
	inst = raw_input().split()
	if inst[0] == "insert":
		array.insert(0,inst[1])
	if inst[0] == "delete":
		array.remove(inst[1])
	if inst[0] == "deleteFirst":
		del array[0]
	if inst[0] == "deleteLast":
		del array[len(array)-1]
print " ".join(i for i in array)

### FIXED CODE ###

n = input()
array = []
base = 0
for i in xrange(n):
    inst = raw_input().split()
    if inst[0][0] == 'i':
        array.append(int(inst[1]))
    elif inst[0] == "delete":
        if int(inst[1]) in array:
            x = array[::-1].index(int(inst[1]))
            if x != -1 and int(inst[1]):
                del array[-x-1]
    elif inst[0][6] == 'F':
        array.pop()
    else:
        base += 1
print (" ".join(map(str,array[base:][::-1])))
n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
gap = [x[i+1]-x[i] for i in range(m-1)]
def dp(n):
    if n == 1:
        return max(x) - min(x)
    else:
        if len(gap) > 0:
            maxGap = max(gap)
            gap.remove(maxGap)
        else:
            maxGap = 0
        return dp(n-1) - maxGap
print(dp(n))

### FIXED CODE ###

n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
gap = sorted([x[i+1]-x[i] for i in range(m-1)])
if n < m:
    print(sum(gap[:m-n]))
else:
    print(0)
N,K = map(int, input().split())
l = list(map(int,input().split()))

j = sum(l[0:0+K])
m = 0
for i in range(1,len(l)-(K-1)):
    j = j - l[i-1] + l[i+K-1]
    if l[i] =< l[i-1]:
        continue
    elif m < j:
        m = j
        t = l[i:i+K]
        
def E(n):
    return sum(range(1,n+1)) / n

l2 = list(map(E, t))

print(sum(l2))

### FIXED CODE ###

N,K = map(int, input().split())
l = list(map(int,input().split()))
 
def E(n):
  return (1 + n) / 2
 
j = sum(l[0:0+K])
m = 0
if N == 1:
  l2 = list(map(E, l))
  print(sum(l2))
elif N == K:
  l2 = list(map(E, l))  
  print(sum(l2))
else:
  for i in range(1,len(l)-(K-1)):
      j = j - l[i-1] + l[i+K-1]
      if l[i] < l[i-1]:
          continue
      elif m < j:
          m = j
          t = l[i:i+K]

  l2 = list(map(E, t))
 
  print(sum(l2))
n, m = map(int, input().split())
if -2 < (n - m) < 2:
  ans = 1
  for i in range(n):
    ans *= n
    ans %= 10_0000_0007
  for i in range(m):
    ans *= n
    ans %= 10_0000_0007
  print(ans)
else:
  print(0)

### FIXED CODE ###

def solve():
    n, m = map(int, input().split())
    if -2 < (n - m) < 2:
        ans = 1
        for i in range(1, n+1):
            ans *= i
            ans %= 1000000007
        for i in range(1, m+1):
            ans *= i
            ans %= 1000000007
        if n != m:
            print(ans)
        else:
            print(((ans) * 2) % 1000000007)
    else:
        print(0)


if __name__=="__main__":
    solve()
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

red = sorted(p, reverse=True)[:X-1]
green = sorted(q, reverse=True)[:Y-1]
white = sorted(r, reverse=True)

original = sorted(red + green)
while original[0] < white[0]:
  original[0] = white[0]
  white.pop(0)
  original.sort()
  
print(sum(original))

### FIXED CODE ###

from collections import deque
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r = sorted(r, reverse=True)

ans_p = deque(p[:X])
ans_q = deque(q[:Y])
ans_r = deque(r)

while (ans_p[-1]<ans_r[0]) or (ans_q[-1]<ans_r[0]):
  if ans_p[-1] <= ans_q[-1]:
    ans_p.pop()
    ans_p.appendleft(ans_r[0])
    ans_r.popleft()
  else:
    ans_q.pop()
    ans_q.appendleft(ans_r[0])
    ans_r.popleft()
  if not ans_r:
    break;
    
ans = sum(ans_p) + sum(ans_q)
print(ans)
s = input()
n = len(s)
a = 0

for t in s:
    if t == 'p':
        a += 1


print(n//2 - b)

### FIXED CODE ###

s = input()
n = len(s)
a = 0

for t in s:
    if t == 'p':
        a += 1


print(n//2 - a)
a = [int(s) for s in input().split()]
N = a[0]
si = a[1]
ti = a[2]
s = [int(input()) for i in range(N)]
s = sorted(s)
X = int(0)
ans = int(0)

while N != X:
    X += 1 
    ans += 1
    if N == X:
        break
    for i in range(min([si-1,N-X])):
        if s[X + i] <= s[X-1] + ti:
            X += 1
        else:
            break

print(ans)

### FIXED CODE ###

a = [int(s) for s in input().split()]
N = a[0]
si = a[1]
ti = a[2]
s = [int(input()) for i in range(N)]
s = sorted(s)
X = int(0)
ans = int(0)

#全員乗るまで繰り返す
while N != X:
    #まずバスを用意して先頭を乗せる
    X += 1 
    ans += 1
    #この時点で全員乗ったら終わりにする
    if N == X:
        break
    #バスの残りsi-1枠に乗れるだけ乗せる
    #そもそも乗客がsi-1人もいない場合は残りのN-X人が上限
    temp = X
    for i in range(min([si-1,N-X])):
        if s[temp + i] <= s[temp-1] + ti:
            X += 1
        else:
            break

print(ans)
s = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
print(s[input()-1])

### FIXED CODE ###

s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(s[int(input())-1])
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
def SR(n):
    return [S() for _ in range(n)]
def LSR(n):
    return [LS() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    b = LI()
    cnt = defaultdict(lambda : 0)
    for i in a:
        cnt[i] += 1
    for i in b:
        if not cnt[i]:
            continue
        cnt[i] += 1
    for i in cnt.values():
        if i > n:
            print("No")
            return
    r = -1
    while 1:
        update = False
        for l in range(n):
            if a[l] == b[l]:
                update = True
                b[l],b[r] = b[r],b[l]
                r -= 1
        if not update:
            break
    print("Yes")
    print(*b)
    return

#Solve
if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
def SR(n):
    return [S() for _ in range(n)]
def LSR(n):
    return [LS() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    b = LI()
    cnt = defaultdict(lambda : 0)
    for i in a:
        cnt[i] += 1
    for i in b:
        if not cnt[i]:
            continue
        cnt[i] += 1
    for i in cnt.values():
        if i > n:
            print("No")
            return
    r = n-1
    while 1:
        update = False
        for l in range(n):
            while r >= 0 and a[r] != b[r]:
                r -= 1
            if a[l] == b[l]:
                update = True
                b[l],b[r] = b[r],b[l]
                r -= 1
        if not update:
            break
    print("Yes")
    print(*b)
    return

#Solve
if __name__ == "__main__":
    solve()
n = int(input())

ans = 0

for i in range(1, int(n ** .5) + 1):
    if n % i == 0:
        m = n // i - 1
        if n % m == n // m:
            ans += m

print(ans)


### FIXED CODE ###

n = int(input())

ans = 0

for i in range(1, int(n ** .5) + 1):
    if n % i == 0:
        m = n // i - 1
        if m > 0 and n % m == n // m:
            ans += m

print(ans)
a, b, c = map(int, input().split())

print(max(0, c - (a - b)))



### FIXED CODE ###

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

print(max(0, c - (a - b)))
n = int(input())
sa = input().split()

a = [0 for i in range(n)]
sumeven = 0
sumodd = 0
for i,sai in enumerate(sa):
    a[i] = int(sai)

    if i % 2 == 0:
        sumeven += a[i]
    else:
        sumodd += a[i]

ret = 0
sm = 0
for i,ai in enumerate(a):
    if i % 2 == 1:
            ret += max(-sm+1-ai,0)
            sm += max(ai, -sm+1)
        else:
            ret += max(sm+1 + ai, 0)
            sm += min(ai, -(sm+1))
ret2 = 0
sm = 0
for i,ai in enumerate(a):
    if i % 2 == 0:
        ret2 += max(-sm+1-ai,0)
        sm += max(ai, -sm+1)
    else:
        ret2 += max(sm+1 + ai, 0)
        sm += min(ai, -(sm+1))
        
print(max(ret,ret2))
    

### FIXED CODE ###

n = int(input())
sa = input().split()

a = [0 for i in range(n)]
sumeven = 0
sumodd = 0
for i,sai in enumerate(sa):
    a[i] = int(sai)

    if i % 2 == 0:
        sumeven += a[i]
    else:
        sumodd += a[i]

ret = 0
sm = 0
for i,ai in enumerate(a):
    if i % 2 == 1:
        ret += max(-sm+1-ai,0)
        sm += max(ai, -sm+1)
    else:
        ret += max(sm+1 + ai, 0)
        sm += min(ai, -(sm+1))
ret2 = 0
sm = 0
for i,ai in enumerate(a):
    if i % 2 == 0:
        ret2 += max(-sm+1-ai,0)
        sm += max(ai, -sm+1)
    else:
        ret2 += max(sm+1 + ai, 0)
        sm += min(ai, -(sm+1))
        
print(min(ret,ret2))
N, M = map(int, input().split())
S=[[0, ""] for j in range(M)]
ACcheck=[False for j in range(N)]
AC=0
WA=[0 for j in range(N)]
WA2 = 0
for i in range(M):
  ps = input().split()
  S[i][0]=int(ps[0])
  S[i][1]=ps[1]
for i in range(M):
  if S[i][1]=="AC":
    if ACcheck[S[i][0]-1]==False:
      AC+=1
      ACcheck[S[i][0]-1]=True
      WA2+=WA[S[i][0]]
  else:
    if ACcheck[S[i][0]-1]==False:
      WA[S[i][0]]+=1

print(AC, WA2)

### FIXED CODE ###

N, M = map(int, input().split())
S=[[0, ""] for j in range(M)]
ACcheck=[False for j in range(N)]
AC=0
WA=[0 for j in range(N)]
WA2 = 0
for i in range(M):
  ps = input().split()
  S[i][0]=int(ps[0])
  S[i][1]=ps[1]
for i in range(M):
  if S[i][1]=="AC":
    if ACcheck[S[i][0]-1]==False:
      AC+=1
      ACcheck[S[i][0]-1]=True
      WA2+=WA[S[i][0]-1]
  else:
    if ACcheck[S[i][0]-1]==False:
      WA[S[i][0]-1]+=1

print(AC, WA2)
N = int(input().strip())

n_list = [[] for i in range(N)]
d = [0] * N

for i in range(N-1):
    a, b = map(int, input().strip().split())
    a -= 1
    b -= 1
    n_list[a].append([b,i])
    n_list[b].append([a,i])
    d[a] += 1
    d[b] += 1


#print(n_list)
#print(d)

d_dict = {}
for i in range(N):
    d_dict[i] = d[i]
tmp = sorted(d_dict.items(), key = lambda x:x[1], reverse = True)

colors = [0] * (N)

root = tmp[0][0]

def paint(node, parent_edge_id):
    #print(node, parent_edge_id)
    tmp_color = 1
    for edge in n_list[node]:
        #print("ege:", edge)
        if edge[1] != parent_edge_id:
            if parent_edge_id != -1 and tmp_color == colors[parent_edge_id]:
                tmp_color += 1
            colors[edge[1]] = tmp_color
            paint(edge[0], edge[1])
            tmp_color += 1

    
try:
    paint(tmp[0][0], -1)
except SyntaxError:
    print(0)
print(tmp[0][1]) # color num    a
for i in range(N-1):
    print(colors[i])

### FIXED CODE ###

import sys
N = int(input().strip())

n_list = [[] for i in range(N)]
d = [0] * N

for i in range(N-1):
    a, b = map(int, input().strip().split())
    a -= 1
    b -= 1
    n_list[a].append([b,i])
    n_list[b].append([a,i])
    d[a] += 1
    d[b] += 1


#print(n_list)
#print(d)

d_dict = {}
for i in range(N):
    d_dict[i] = d[i]
tmp = sorted(d_dict.items(), key = lambda x:x[1], reverse = True)

colors = [0] * (N)

root = tmp[0][0]

def paint(node, parent_edge_id):
    #print(node, parent_edge_id)
    tmp_color = 1
    for edge in n_list[node]:
        #print("ege:", edge)
        if edge[1] != parent_edge_id:
            if parent_edge_id != -1 and tmp_color == colors[parent_edge_id]:
                tmp_color += 1
            colors[edge[1]] = tmp_color
            paint(edge[0], edge[1])
            tmp_color += 1

    
sys.setrecursionlimit(10**7)
paint(tmp[0][0], -1)
print(tmp[0][1]) # color num 
for i in range(N-1):
    print(colors[i])