Harryxun/stf_run huggingface dataset:
from sys import stdin

input = stdin.buffer.readline

n = int(input())
v = [[] for _ in range(n+1)]
edge = [0] * -~n

ans = 0


def dfs(c,fa,x):
    global ans
    color = 1
    for to, eg in v[x]:
        if to == fa:
            continue
        if color == c:
            color += 1
        edge[eg] = color
        ans = max(ans, color)
        dfs(color, x, to)
        color += 1


for i in range(n - 1):
    a, b = map(int, input().split())
    v[a].append([b, i])
    v[b].append([a, i])

dfs(0,0,1)
print(ans)
for i in range(n-1):
    print(edge[i])






### FIXED CODE ###

from sys import stdin

input = stdin.buffer.readline

n = int(input())
v = [[] for _ in range(n+1)]
edge = [0] * -~n

ans = 0


def dfs(c,fa,x):
    global ans
    color = 1
    for to, eg in v[x]:
        if to == fa:
            continue
        if color == c:
            color += 1
        edge[eg] = color
        ans = max(ans, color)
        dfs(color, x, to)
        color += 1


def bfs(x):
    q = [[0,0,x]]
    ans = 0
    while len(q):
        c, fa, now = q.pop()
        color = 1
        for to, eg in v[now]:
            if to == fa:
                continue
            if color == c:
                color += 1
            edge[eg] = color
            q.append([color, now, to])
            ans = max(ans, color)
            color += 1
    return ans


for i in range(n - 1):
    a, b = map(int, input().split())
    v[a].append([b, i])
    v[b].append([a, i])

print(bfs(1))
for i in range(n-1):
    print(edge[i])
N = int(input())

ret = 0
for i in range(1, N + 1) :
  j = N // i
  if j < 1 :
    break
  ret += (1 + j) * i * j // 2
  
print(ret)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = [0] + [int(i) for i in input().split()]
B = [0] + [int(i) for i in input().split()]

N += 1
M += 1
for i in range(1, N) :
  A[i] += A[i - 1]
for i in range(1, M) :
  B[i] += B[i - 1]

ret = 0
a = N - 1
b = 0
while b < M :
  while a >= 0 and A[a] + B[b] > K :
    a -= 1
  if a >= 0 and A[a] + B[b] <= K :
    ret = max(ret, a + b)
  b += 1
  
print(ret)
a=input()
b=input()
int(a)
int(b)
if a>b:
  print(2*a-1)
elif a==b:
  print(2*a)
else:
  print(2*b-1)

### FIXED CODE ###

a,b=map(int, input().split())
if a>b:
  print(2*a-1)
elif a==b:
  print(2*a)
else:
  print(2*b-1)
from decimal import *
c, d = list(map(decimal, input().split()))
print(int(c * d))

### FIXED CODE ###

from decimal import Decimal

C, D = map(Decimal, input().split())
print(int(C*D))
import sys
from  collections import deque
sys.setrecursionlimit(10^7)
def dfs(base, n, s, cur):
  if cur == n:
    return 1
  else:
    return (dfs(base, n, s, cur+1)+(0 if base[cur] in s else dfs(base, n, s+base[cur], cur+1)))%(10^9+7)

N = int(input())
S = list(input().strip())
print(dfs(S,N,"",0)-1)



### FIXED CODE ###

from itertools import combinations
N = int(input())
S = list(input().strip())
d = {}
for c in S:
  if c in d.keys():
    d[c] += 1
  else:
    d[c] = 1
ans = 0
for n in d.values():
  ans = (ans+n+ans*n)%(10**9+7)
print(ans)
MOD = 1000000007
def fast_power(base, power):
    """
    Returns the result of a^b i.e. a**b
    We assume that a >= 1 and b >= 0

    Remember two things!
     - Divide power by 2 and multiply base to itself (if the power is even)
     - Decrement power by 1 to make it even and then follow the first step
    """

    result = 1
    while power > 0:
        # If power is odd
        if power % 2 == 1:
            result = (result * base) % MOD

        # Divide the power by 2
        power = power / 2
        # Multiply base to itself
        base = (base * base) % MOD

    return result


s = input()
k = int(input())

tyo = 5e15

char = [int(ss) for ss in s]

res = 0

_sum = 0
ok = 0

for i in range(k):
    _sum = _sum + (fast_power(s[i], tyo))
    if _sum >= k and ok == 0:
        res = s[i]
        ok = 1

# for num in char:
#     _sum = _sum + (fast_power(num, tyo))
#     if _sum >= k and ok == 0:
#         res = num
#         ok = 1

print(res)


### FIXED CODE ###

from math import pow
s = input()
k = int(input())

char = [ss for ss in s]


res = '1'

_sum = 0
for i in range(k):
    if s[i] != '1':
        res = s[i]
        break

print(res)
s = int(input())
h,m,s = s / 3600, (s/60)%60, s%60
printf("%d:%d:%d",h,m,s)

### FIXED CODE ###

#!/usr/bin/env python3
s = int(input())
h, m, s = int(s / 3600), int(s / 60) % 60, s % 60
print(h, m, s, sep=':')
n,x = map(int,input().split())
listl = []
listl += map(int,input().split())
# print(listl)

cnt=1
d=0
# print(d)
for i in range(n):
    d = d+listl[cnt]
    if d > x:
        break
    # print(d)
    cnt+=1

print(cnt)

### FIXED CODE ###

n,x = map(int,input().split())
l = list(map(int,input().split()))
# print(listl)

cnt=1
d=0
# print(d)
for i in range(len(l)):
    d = d+l[i]
    if d > x:
        break
    # print(d)
    cnt+=1

print(cnt)
import numpy as np


def main():
    # H, W = [int(x) for x in input().split()]
    H, W = map(int, [int(x) for x in input().split()])
    board = [[0 for i in range(H)] for j in range(W)]

    """ #は1, .は0 """
    for i in range(H):
        X = input()
        X_len = len(X)
        for j in range(X_len):
            if X[j] == "#":
                board[i][j] = 1

    num_board = np.array(board)
    height, width = num_board.shape[:2]
    count = 0
    while (np.sum(num_board) != height*width):
        num_board_ans = np.zeros((height, width))
        for i in range(height):
            if np.sum(num_board[:, j]) == width:
                continue
            for j in range(width):
                if num_board[i, j] == 1:
                    num_board_ans[i, j] = 1
                    a = max(i-1, 0)
                    num_board_ans[a, j] = 1
                    b = max(j-1, 0)
                    num_board_ans[i, b] = 1
                    c = min(i+1, height-1)
                    num_board_ans[c, j] = 1
                    d = min(j+1, width-1)
                    num_board_ans[i, d] = 1
        num_board = num_board_ans
        count += 1

    print(count)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def bfs(h, w, board, visited):
    queue = deque([])
    for i in range(h):
        for j in range(w):
            if board[i][j] == "#":
                queue.append([i, j])
                visited[i][j] = 0
    ans = 0
    while queue:
        y, x = queue.popleft()
        for i, j in ([1, 0], [0, 1], [-1, 0], [0, -1]):
            yn, xn = y+i, x+j
            if yn >= h or xn >= w or yn < 0 or xn < 0:
                continue
            if visited[yn][xn] == -1 and board[yn][xn] == ".":
                visited[yn][xn] = visited[y][x] + 1
                queue.append([yn, xn])
                ans = max(ans, visited[yn][xn])

    return ans


def main():
    h, w = map(int, input().split())
    board = [input() for _ in range(h)]
    visited = [[-1 for _ in range(w)] for _ in range(h)]
    print(bfs(h, w, board, visited))


if __name__ == "__main__":
    main()
N, Q = map(int, input().split())
S = input()
AC = [0] * N

for i in range(1, len(S)):
    if S[i-1] == 'A' and S[i] == 'C':
        AC[i] = AC[i-1] + 1
    else:
        AC[i] = AC[i-1]


for i in range(Q):
    start, end = map(lambda x:int(x)-1, input().split())
    print(AC[end] - AC[start])

### FIXED CODE ###

b = input()

if b == 'A':
  print('T')
elif b == 'T':
  print('A')
elif b == 'C':
  print('G')
else:
  print('C')
N = int(input())
a = [int(x) for x in input().split()]

def brickblock(lst, flag=False, target=1, res=0):
	if not lst:
		if flag:
			return res
		else:
			return -1
	elif lst[0] == target:
		return brickblock(lst[1:], True, target+1, res)
	else:
		return brickblock(lst[1:], flag, target, res+1)

res = brickblock(a)
print(res)

### FIXED CODE ###

N = int(input())
a = [int(x) for x in input().split()]
# a = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]

target = 1
res = 0
flag = False

for x in a:
	if x == target:
		target += 1
		flag = True
	else:
		res += 1

if flag:
	print(res)
else:
	print(-1)
import re
s=input()
count=0
result=re.search(r'[ACGT]+',s)
i=result.group()
for _ in i:
    count+=1
print(count)

### FIXED CODE ###

s=input()
count=0
a=0
for i in s:
    if i=='A' or i=='C' or i=='G' or i=='T':
        count+=1
        if a<count:
            a=count
    else:
        count=0
print(a)
import math

N=int(input())
A=list(map(int,input().split()))
l=[]

if 0 not in A:
  for i in A:
  l.append(math.log10(A[i]))
  if sum(l)<18: 
    print(int(10**sum(l)))
  else:
    print(‘-1’)
else:
  print(‘0’)

### FIXED CODE ###

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

if 0 in a:
  print(0)

else:
  ans = 1
  for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
      print(-1)
      exit()
  print(ans)
n, m = map(int, input().split())

a = list(map(int, input().split()))
a.sort(reverse=True)
total = sum(a)

canPick = True
for i in range(m):
    if a[m] < total / (4 * m):
        canPick = False

if canPick is True:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

n, m = map(int, input().split())

a = list(map(int, input().split()))
a.sort(reverse=True)
total = sum(a)

canPick = True
for i in range(m):
    if a[i] < total / (4 * m):
        canPick = False

if canPick is True:
    print("Yes")
else:
    print("No")
def main():
    a = input()
    if 'a' in a and 'b' in a and 'c' in a:
        print("yes", end=")
    else:
        print("no", end=")

if __name__ == "__main__":
    main()   

### FIXED CODE ###

def main():
    a = input()
    if 'a' in a and 'b' in a and 'c' in a:
        print("Yes", end="")
    else:
        print("No", end="")

if __name__ == "__main__":
    main()
N=int(input())
P=[int(input()) for i in range (N)]
print(sum(N) - max(N)//2)

### FIXED CODE ###

N=int(input())
P=[int(input()) for i in range (N)]
print(sum(P) - max(P)//2)
n,l = map(int,input().split())
print("".join(sorted([ input() for i in range(n)])))


### FIXED CODE ###

abc =input()
five = abc.count("5")
seven = abc.count("7")
 
if five==2 and seven==1:
  print("YES")
else:
  print("NO")
from collections import deque

H, W = map(int, input().split())

H += 2
W += 2

grid = "#" * W
for _ in range(H - 2):
    grid += "#" + input().split()
grid += "#" * W


def bfs(start):
    INF = 10 * 9
    dist = [INF] * (H * W)
    dist[start] = 0
    q = deque([start])
    while q:
        v = q.popleft()
        dv = dist[v]
        for move in (-1, 1, W, -W):
            # next place
            w = v + move
            # wall or not
            if grid[w] == "#":
                continue

            dw = dv + 1
            if dw >= dist[w]:
                continue
            dist[w] = dw
            q.append(w)

    return max(x for x in dist if x < INF)


answer = max(bfs(v) for v in range(H * W) if grid[v] != "#")
print(answer)


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())

H += 2
W += 2

grid = "#" * W
for _ in range(H - 2):
    grid += "#" + input() + "#"
grid += "#" * W


def bfs(start):
    INF = 10 ** 9
    dist = [INF] * (H * W)
    dist[start] = 0
    q = deque([start])
    while q:
        v = q.popleft()
        dv = dist[v]
        for move in (-1, 1, W, -W):
            # next place
            w = v + move
            # wall or not
            if grid[w] == "#":
                continue

            dw = dv + 1
            if dw >= dist[w]:
                continue
            dist[w] = dw
            q.append(w)

    return max(x for x in dist if x < INF)


answer = max(bfs(v) for v in range(H * W) if grid[v] != "#")
print(answer)
H,W,D = map(int, input().split())
fields = []
amaris = [[0] * (H*W)//D+1 for i in range(D)] # あまり
for i in range(H):
    row = list(map(int, input().split()))
    # あまりがいくつかで分類
    for j,e in enumerate(row):
        n = (e-1) // D
        m = (e-1) % D
        amaris[m][n] = (i,j)

# print(amaris[:10])
# あまりごとに累積和を取っておく
acc = [[0] * (H*W)//D+1 for i in range(D)]
for i in range(D):
    cnt = 0
    x_pre, y_pre = amaris[i][0]
    for j in range(1,(H*W)//D+1):
        coords = amaris[i][j]
        if isinstance(coords,int): break
        x = coords[0]
        y = coords[1]
        cnt += abs(x-x_pre)+abs(y-y_pre)
        acc[i][j] = cnt
        x_pre = x
        y_pre = y

# print(acc)

Q = int(input())
for i in range(Q):
    l,r  = map(int, input().split())
    m = (l-1) % D
    s = (l-1) // D
    g = (r-1) // D
    ans = acc[m][g] - acc[m][s]
    print(ans)



### FIXED CODE ###

H,W,D = map(int, input().split())
fields = []
amaris = [[0] * (H*W//D+1) for i in range(D)] # あまり
for i in range(H):
    row = list(map(int, input().split()))
    # あまりがいくつかで分類
    for j,e in enumerate(row):
        n = (e-1) // D
        m = (e-1) % D
        amaris[m][n] = (i,j)

# あまりごとに累積和を取っておく
acc = [[0] * (H*W//D+1) for i in range(D)]
for i in range(D):
    cnt = 0
    x_pre, y_pre = amaris[i][0]
    for j in range(1,(H*W)//D+1):
        coords = amaris[i][j]
        if isinstance(coords,int): break
        x = coords[0]
        y = coords[1]
        cnt += abs(x-x_pre)+abs(y-y_pre)
        acc[i][j] = cnt
        x_pre = x
        y_pre = y
# print(acc)

Q = int(input())
for i in range(Q):
    l,r  = map(int, input().split())
    m = (l-1) % D
    s = (l-1) // D
    g = (r-1) // D
    ans = acc[m][g] - acc[m][s]
    print(ans)
import itertools
import math
N = int(input())
As =list(map(int,input().split(" ")))
odds = 0
two = 0
four = 0
nums = []
for a in As:
    if a % 2 == 1:
        odds += 1
    elif a % 4 == 0:
        four += 1
    else:
        two += 1
if odds > 0:
    nums.append(1)
    odds -= 1
elif two > 0:
    nums.append(2)
    two -=1
else:
    nums.append(4)
    four-=1
ans = "Yes"

if N==2:
    if As[0] * As[1]%4 !=0:
       ans = "No"
else:
    for i in range(1,N):
        if nums[i-1] == 1:
            if four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"
        elif nums[i - 1] == 2:
            if two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"

        elif nums[i - 1] == 4:
            if odds> 0:
                nums.append(1)
                odds -= 1
            elif two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1

print(ans)

### FIXED CODE ###

import itertools
import math
N = int(input())
As =list(map(int,input().split(" ")))
odds = 0
two = 0
four = 0
nums = []
for a in As:
    if a % 2 == 1:
        odds += 1
    elif a % 4 == 0:
        four += 1
    else:
        two += 1
if odds > 0:
    nums.append(1)
    odds -= 1
elif two > 0:
    nums.append(2)
    two -=1
else:
    nums.append(4)
    four-=1
ans = "Yes"

if N==2:
    if As[0] * As[1]%4 !=0:
       ans = "No"
else:
    for i in range(1,N):
        if nums[i-1] == 1:
            if four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"
                break
        elif nums[i - 1] == 2:
            if two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1
            else:
                ans = "No"
                break
        elif nums[i - 1] == 4:
            if odds> 0:
                nums.append(1)
                odds -= 1
            elif two> 0:
                nums.append(2)
                two -= 1
            elif four > 0:
                nums.append(4)
                four -=1

print(ans)
def somesum(n):
    sum = 0
    x = n
    while int(x / 10) > 0:
        sum += x % 10
        x = int(x / 10)
    sum += x % 10
    return sum
    
n,a,b = map(int,input().split())
sum = 0
for val in range(1,n+1):
    if somesum(val) >= a and somesum(val) <= b:
        sum += val
print(sum)

### FIXED CODE ###

a,b,c,d = map(int,input().split())
L = a+b
R = c+d
if L > R:
  print('Left')
elif L < R:
  print('Right')
else:
  print('Balanced')
N, M = map(int, input().split())
adj_matrix = [[0]*N for _ in range(N)]

for i in range(N):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

def dfs(v, used):
    if not False in used:
        return 1

    ans = 0
    for i in range(N):
        if not adj_matrix[v][i]:
            continue
        if used[i]:
            continue
        used[i] = True
        ans += dfs(i, used)
        used[i] = False        
    return ans

used = [False] * N
used[0] = True
print(dfs(0, used))

### FIXED CODE ###

import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M): #隣接行列
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)
k=int(input())
a=int(input())
b=int(input())
c=0
for i in range(a,b+1):
  if i%k==0:
    c=c+1
if c==0:
  print("NG")
else:
  print("OK")

### FIXED CODE ###

k=int(input())
A,B = input().split(" ")
A = int(A)
B = int(B)
c=0
for i in range(A,B+1):
  if i%k==0:
    c=c+1
if c==0:
  print("NG")
else:
  print("OK")
input = input(“天気を入力：”)
items = {'apple': 100, 'banana': 200, 'orange': 400}
print( items[input] )

### FIXED CODE ###

input = input()
items = {'Sunny': 'Cloudy', 'Cloudy':'Rainy', 'Rainy': 'Sunny'}
print( items[input] )
s = input()
print("{}{}{}".format(s[0],len(s)-2,s[-1]))

### FIXED CODE ###

s=input()
print(s[0]+str((len(s)-2))+s[-1])
from sys import stdin

nn = input()

N=int(nn)

arr=list(map(int,input().split()))


if 0 in arr:
    print(0)
    exit()

res=1
for i in arr:
    res*=i
    if res>1000000000000000000:
        print(-1)
        exit();

print(res)

### FIXED CODE ###

from sys import stdin

nn = input()

N=int(nn)

arr=list(map(int,input().split()))


if 0 in arr:
    print(0)
    exit()

res=1
for i in arr:
    res*=i
    if res>1000000000000000000:
        print(-1)
        exit();

print(res)
l = list(map(int, input().split()))

def attack(l):
    H = l[0]
    A = l[1]
    cnt = 0
    while H >= 0:
        H = H - A
        cnt += 1
    return cnt

print(cnt)


### FIXED CODE ###

l = list(map(int, input().split()))

def attack(l):
    H = l[0]
    A = l[1]
    cnt = 0
    while H > 0:
        H -= A
        cnt += 1
    return cnt

print(attack(l))
from numpy import*;v,c=loadtxt(open(0),'i',skiprows=1);i=v>c;print(sum(v[i]-c[i]))

### FIXED CODE ###

n,*t=map(int,open(0).read().split());print(sum((x-y)*(x>y)for x,y in zip(t[:n],t[n:])))
task =  [int (i) for i in input.split(" ")]
ans=5000
if abs(task[0]-task[1])+abs(task[2]-task[0]) < ans:
	ans = abs(task[0]-task[1])+abs(task[2]-task[0])
if abs(task[0]-task[2])+abs(task[1]-task[0]) < ans:
	ans = abs(task[0]-task[2])+abs(task[1]-task[0])
if abs(task[1]-task[0])+abs(task[2]-task[1]) < ans:
	ans = abs(task[1]-task[0])+abs(task[2]-task[1])
if abs(task[1]-task[2])+abs(task[0]-task[1]) < ans:
	ans = abs(task[1]-task[2])+abs(task[0]-task[1])
if abs(task[2]-task[0])+abs(task[1]-task[2]) < ans:
	ans = abs(task[2]-task[0])+abs(task[1]-task[2])
if abs(task[2]-task[1])+abs(task[0]-task[2]) < ans:
	ans = abs(task[2]-task[1])+abs(task[0]-task[2])
print(ans)

### FIXED CODE ###

task = input().split(" ")
ans = 5000
if abs ( int(task [ 0 ]) - int(task [ 1 ])) + abs ( int(task [ 2 ]) - int(task [ 0 ])) < ans : 
	ans = abs ( int(task [ 0 ]) - int(task [ 1 ])) + abs ( int(task [ 2 ]) - int(task [ 0 ]))
if abs ( int(task [ 0 ]) - int(task [ 2 ])) + abs ( int(task [ 1 ]) - int(task [ 0 ])) < ans : 
	ans = abs ( int(task [ 0 ]) - int(task [ 2 ])) + abs ( int(task [ 1 ]) - int(task [ 0 ]))
if abs ( int(task [ 1 ]) - int(task [ 0 ])) + abs ( int(task [ 2 ]) - int(task [ 1 ])) < ans : 
	ans = abs ( int(task [ 1 ]) - int(task [ 0 ])) + abs ( int(task [ 2 ]) - int(task [ 1 ]))
if abs ( int(task [ 1 ]) - int(task [ 2 ])) + abs ( int(task [ 0 ]) - int(task [ 1 ])) < ans : 
	ans = abs ( int(task [ 1 ]) - int(task [ 2 ])) + abs ( int(task [ 0 ]) - int(task [ 1 ]))
if abs ( int(task [ 2 ]) - int(task [ 0 ])) + abs ( int(task [ 1 ]) - int(task [ 2 ])) < ans : 
	ans = abs ( int(task [ 2 ]) - int(task [ 0 ])) + abs ( int(task [ 1 ]) - int(task [ 2 ]))
if abs ( int(task [ 2 ]) - int(task [ 1 ])) + abs ( int(task [ 0 ]) - int(task [ 2 ])) < ans : 
	ans = abs ( int(task [ 2 ]) - int(task [ 1 ])) + abs ( int(task [ 0 ]) - int(task [ 2 ]))
print ( ans )
s, w = map(int, input().spilt())

if w >= s:
  print("unsafe")
else:
  print("safe")
  

### FIXED CODE ###

S,W = map(int, input().split())

if S<=W:
  print("unsafe")
else:
  print("safe")
# coding:utf-8
x, n = map(int, input().split())
p = list(map(int, input().split()))


if n == 0:
    print(x)
else:
    ps = sorted(p)
    tmp = [_ for _ in range(ps[0], ps[-1] + 1)]
    ans_list = list(set(tmp) ^ set(ps))
    # print(tmp, ans_list)
    diff = []

    for i in ans_list:
        diff.append(abs(i - x))
    print(ans_list[diff.index(min(diff))])


### FIXED CODE ###

# coding:utf-8
x, n = map(int, input().split())
p = list(map(int, input().split()))


if n == 0:
    print(x)
else:
    ps = sorted(p)
    tmp = list(range(-201, 200))
    ans_list = list(set(tmp) ^ set(ps))
    ans_list = sorted(ans_list)
    # print(tmp, ans_list)
    diff = []

    for i in ans_list:
        diff.append(abs(i - x))

    print(ans_list[diff.index(min(diff))])
from fractions import gcd
A,B=map(int,input().split())
def lcd(x,y)
  return (x * y) // gcd(x, y)
print(lcd(A,B))

### FIXED CODE ###

from fractions import gcd
A,B=map(int,input().split())
def lcd(x,y):
  return (x * y) // gcd(x, y)
print(lcd(A,B))
a,b,c,d = [int(input) for _ in renge(4)]
print(min(a,b) + min(c,d))


### FIXED CODE ###

a,b,c,d = [int(input()) for _ in range(4)]
print(min(a,b) + min(c,d))
import sys
from collections import deque
import numpy as np

def main():
    n = int(sys.stdin.readline().rstrip())
    ab = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(-1, 2)

    G = [[] for _ in range(n + 1)]
    for a, b in ab:
        G[a].append(b)
        G[b].append(a)
    
    parent = np.zeros(n + 1, dtype=np.int64)
    color = np.zeros((n + 1, n + 1), dtype=np.int64)
    root = 1
    ng = None
    q = deque()
    q.append((root, ng))

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

    print(np.amax(color))
    for a, b in ab:
        print(color[a][b])
            
if __name__ == '__main__':
    main()

### FIXED CODE ###

# 2019-11-24 20:59:47(JST)
import sys

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

    graph = [[] for _ in range(n + 1)]
    for a, b in ab:
        graph[a].append(b)
        graph[b].append(a)

    root = 1
    parent = [0] * (n + 1)
    order = []
    stack = [root]

    while stack:
        x = stack.pop()
        order.append(x)
        for y in graph[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            stack.append(y)

    color = [-1] * (n + 1)
    for x in order:
        ng = color[x]
        c = 1
        for y in graph[x]:
            if y == parent[x]:
                continue
            if c == ng:
                c += 1
            color[y] = c
            c += 1

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

    print(max(res))
    print('\n'.join(map(str, res)))


if __name__ == '__main__':
    main()
s, t = input().split() 
a, b = input().split() 
u = input()
int(a)
int(b)
if u == s:
    a = a-1
else:
    b = b-1
print(a+' '+b)

### FIXED CODE ###

s, t = input().split() 
a, b = input().split() 
u = input()


if u == s:
    a = str(int(a)-1)
else:
    b = str(int(b)-1)

print(a+' '+b)
a,b = map(int, input().split()) 
print(b-a a%b a+b)

### FIXED CODE ###

a, b = map(int, input().split())
print(b-a if b%a else a+b)