Harryxun/stf_run huggingface dataset:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  N,K=LI()
  P=LI()
  P=[0]+P
  C=LI()
  C=[0]+C

  l=[[0] for _ in range(N)]
  check=[[False]*(N+1) for _ in range(N)]
  roop=[]
  for i in range(N):
    zahyo=i+1
    check[i][zahyo]=True
    f=False
    for j in range(N+1):
      zahyo=P[zahyo]
      if check[i][zahyo] and not f:
        roop.append(j+1)
        f=True
      score=C[zahyo]
      l[i].append(l[i][-1]+score)
  # for i in range(N):
  #   print(l[i])
  # print(roop)

  ans=0
  for i in range(N):
    roop_count=roop[i]
    if K<=roop_count:
      ans=max(ans,max(l[i][1:K+1])) # 1巡以内
    else:
      ans=max(ans,max(l[i][1:K+1])) # 1巡以内

      # 2巡目以降（1巡で負になるなら回らない方がいい）
      if l[i][roop_count]>0:
        c=K//roop_count
        _ans1=c*l[i][roop_count]
        k=K%roop_count
        _ans1+=max(l[i][1:k+1]+[0])
        ans=max(ans,_ans1)

        # 可能な巡数まで行かない方がいい場合も
        _ans2=(c-1)*l[i][roop_count]
        _ans2+=max(l[i][:roop_count])
        ans=max(ans,_ans1,_ans2)
        print(i,l[i][:K+1],_ans2)

  return ans

# main()
print(main())


### FIXED CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  N,K=LI()
  P=LI()
  P=[0]+P
  C=LI()
  C=[0]+C

  l=[[0] for _ in range(N)]
  check=[[False]*(N+1) for _ in range(N)]
  roop=[]
  for i in range(N):
    zahyo=i+1
    check[i][zahyo]=True
    f=False
    for j in range(N+1):
      zahyo=P[zahyo]
      if check[i][zahyo] and not f:
        roop.append(j+1)
        f=True
      score=C[zahyo]
      l[i].append(l[i][-1]+score)
  # for i in range(N):
  #   print(l[i])
  # print(roop)

  ans=-inf
  for i in range(N):
    roop_count=roop[i]
    if K<=roop_count:
      ans=max(ans,max(l[i][1:K+1])) # 1巡以内
    else:
      ans=max(ans,max(l[i][1:K+1])) # 1巡以内

      # 2巡目以降（1巡で負になるなら回らない方がいい）
      if l[i][roop_count]>0:
        c=K//roop_count
        _ans1=c*l[i][roop_count]
        k=K%roop_count
        _ans1+=max(l[i][1:k+1]+[0])
        ans=max(ans,_ans1)

        # 可能な巡数まで行かない方がいい場合も
        _ans2=(c-1)*l[i][roop_count]
        _ans2+=max(l[i][:roop_count]+[0])
        ans=max(ans,_ans1,_ans2)

  return ans

# main()
print(main())
#AIsing2020 d
 
import sys,math,collections,itertools,copy
input = sys.stdin.readline
 
 
def popcount(n):
    bin_str = bin(n)
    cou1 = bin_str.count('1')
    return cou1
 
def count(nc):
    co = 0
    while nc >0:
        cou1 = popcount(nc)
        nc = nc%cou1
        co +=1
    return co
 
N = int(input())
X = list(input().rstrip())
X10 = int('0b'+"".join(X),2)
X10_num1 = popcount(X10)
X10_pulse = X10%(X10_num1+1)
X10_ninus = X10%(X10_num1-1)


for i in range(N,0,-1):
    a = X10
    if a>>(i-1) & 1:
        a -= 2**(i-1)
        amari = (X10_ninus - (2**(i-1))%(X10_num1-1))%(X10_num1-1)
        #print(bin(X10),bin(a),X10,a,amari)
    else:
        a += 2**(i-1)
        amari = (X10_pulse + (2**(i-1))%(X10_num1+1))%(X10_num1+1)
        #print(bin(X10),bin(a),X10,a,amari)

    if a ==0:
        co = 0
    else:
        co = count(amari)+1
    print(co)


### FIXED CODE ###

#AIsing2020 d

def f(n):
        cnt = 0
        while n:
            cnt+= 1
            n = n%bin(n).count('1')
        return cnt

def main():
    N = int(input())
    X = input()
    X10 = int(X,2)
    X10_num1 = X.count('1')
    X10_pulse = X10%(X10_num1+1)
    X10_ninus = X10%(X10_num1-1) if X10_num1 >1 else 0


    for i in range(N,0,-1):
        j = N-i
        if (X[j] == '1') and X10_num1 >1:
            mod = X10_num1-1
            amari = (X10_ninus - pow(2,i-1,mod))%(mod) 
        elif (X[j] == '1') and X10_num1 ==1:
            print(0)
            continue
        else:
            mod = X10_num1+1
            amari = (X10_pulse + pow(2,i-1,mod))%(mod)

        print(1+f(amari))


main()
N = int(input())
T = [int(input()) for _ in range(N)]
def gcd(a,b):
    if b:
        return gcd(b,a%b)
    else:
        return a

def lcm(a,b):
    g = gcd(a,b)
    return a*b//g

l = lcm(T[0],T[1])
for i in range(2,N):
    l = lcm(l,T[i])

print(l)

### FIXED CODE ###

"""
すべての秒数の最小公倍数を求める
Gを最大公約数として持つX,Yの最小公倍数はG*X/G*Y/G
"""
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
N = int(input())
T = [int(input()) for _ in range(N)]
tmp = T[0]
for i in range(1,N):
    t = T[i]
    g = gcd(tmp,t)
    tmp = g*(tmp//g)*(t//g)
print(tmp)
import fractions
n, m = map(int, input().split())
a = list(map(int, input().split()))
num = 1
cnt = []
for x in a:
    c = 0
    for i in range(int(math.log(x,2))+1):
        if x>>c&1:
            break
        else:
            c+=1
    cnt.append(c)
if max(cnt) != min(cnt):
    print(0)
else:
    for x in a:
        num = num * (x//2) // fractions.gcd(num, x//2)
    print(m//num-(m//num)//2)

### FIXED CODE ###

import math
import fractions
n, m = map(int, input().split())
a = list(map(int, input().split()))
num = 1
cnt = []
for x in a:
    c = 0
    for i in range(int(math.log(x,2))):
        if x>>c&1:
            break
        else:
            c+=1
    cnt.append(c)
if max(cnt) != min(cnt):
    print(0)
else:
    for x in a:
        num = num * (x//2) // fractions.gcd(num, x//2)
    print(m//num-(m//num)//2)
#! /usr/bin/python
# -*- encoding: utf-8 -*-


if __name__ == '__main__':
    input = list(map(int, input().split()))
    inputA = input[0]
    inputB = input[1]

    if inputA == inputB:
      print("IMPOSSIBLE")

    elif (inputA + inputB) % 2 == 0:
      print(int((inputA + inputB) / 2))
      
    elif (inputA + inputB) % 2 != 0:
      print("IMPOSSIBLE")

    else:
      print("IMPOSSIBLE")

### FIXED CODE ###

#! /usr/bin/python
# -*- encoding: utf-8 -*-

import sys

if __name__ == '__main__':
    input = list(map(int, input().split()))
    inputA = input[0]
    inputB = input[1]
    
    if inputA < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()
    
    if inputB < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if inputA == inputB:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if (inputA + inputB) % 2 == 0:
        sys.stdout.write(str(int((inputA + inputB) / 2)))
        sys.exit()
      
    sys.stdout.write("IMPOSSIBLE")
    sys.exit()
import math
a,b,x = map(int,input().split())
c = (2*x)/(a*b)
if c <= a:
    d = math.sqrt(b**2+c**2)
    cosB = (c**2+d**2-b**2)/(2*c*d)
    acosB = math.degrees(math.acos(cosB))
    ans = acosB
else:
    c = 2*x/a**2-b
    c2 = b-c
    d = math.sqrt(a**2+c2**2)
    cosA = (c2**2+d**2-a**2)/(2*c2*d)
    acosA = math.degrees(math.acos(cosA))
    ans = 90-acosA
print(ans)

### FIXED CODE ###

import math
a,b,x = map(int,input().split())
full = a*a*b
ans = 0
if x == full:
    ans = 0
elif x<=full/2:
    c = (2*x)/(a*b)
    d = math.sqrt(b**2+c**2)
    cosB = (c**2+d**2-b**2)/(2*c*d)
    acosB = math.degrees(math.acos(cosB))
    ans = acosB
else:
    c = 2*x/a**2-b
    c2 = b-c
    d = math.sqrt(a**2+c2**2)
    cosA = (c2**2+d**2-a**2)/(2*c2*d)
    acosA = math.degrees(math.acos(cosA))
    ans = 90-acosA
print(ans)
import math
r = int(raw_input())
V = r*r*math.pi
S = 2*r*math.pi

print '{0} {1}'.format(V, S)

### FIXED CODE ###

import math
r = float(raw_input())
V = r*r*math.pi
S = 2*r*math.pi

print '%f %f' %(V, S)
from scipy.special import comb, factorial

print(input())
print(comb(3, 1, exact=True)

### FIXED CODE ###

from scipy.misc import comb

n, k = tuple(map(int, input().split(' ')))
for i in range(1, k+1):
    # 青玉k個をi個の群に分割する。これはk個の青玉の間のk-1箇所のいずれかからi-1個を選んで仕切りとすることで可能
    # これはk-1Ci-1
    # その上で、できたi個の群の前後i+1箇所に赤玉を埋めていく
    # はじめに、i個の群の内側であるi-1箇所には必ず1つ以上赤玉が存在しなければならないので、予めi-1個の赤玉を配置したものとみなす
    # 結局、n-k-(i-1)=n-k-i+1個の赤玉をi+1箇所のどこかにおいていくことと同値
    # これはn-k-i+1個の赤玉とi個の仕切りの並べ方であるので、(n-k+1)Ci
    # 以上より、求める答えはk-1Ci-1 * (n-k+1)Ci
    s = comb(k-1, i-1, exact=True) * comb(n-k+1, i, exact=True)
    print(int(s) % (10 ** 9 + 7))
n,x = map(int,input().split())

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

k = []
s = []
for i in range(n):
  k[i] += l[i]
  s[i] = k[i]

c = 0
for i in s:
  if i <= x:
    c += 1

print(c)

### FIXED CODE ###

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

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

k = 0
s = []
for i in range(n):
  k += l[i]
  s.append(k)

c = 0
for i in s:
  if i <= x:
    c += 1

print(c+1)
def findSumOfDigits(n):
    sum = 0
    while n > 0.1:
        sum = sum + (n % 10)
        #print(n % 10)
        n = n - (n % 10)
        n = n / 10
    return sum

# 整数の入力
n = input()
n = int(n)

a = input()
a = int(a)

b = input()
b = int(b)

ans = 0

for i in range(1,n+1):
    #print(i)
    test = findSumOfDigits(i)
    if a <= test <= b:
        ans = ans + i

print(int(ans))

### FIXED CODE ###


# スペース区切りの整数の入力
a, b, c, d = map(int, input().split())

if a+b > c+d:
    print('Left')
elif a+b < c+d:
    print('Right')
else:
    print('Balanced')
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll gcd(ll a, ll b) {
    if(a < b) return gcd(b, a);
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}


int main(){
    ll n, m, a[101000];
    cin >> n >> m;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] /= 2;
    }

    ll hist = a[0];
    for(int i = 1; i < n; i++){
        if(hist > m){
            cout << 0 << endl;
            return 0;
        }
        ll x = hist * a[i] / gcd(hist, a[i]);
        if((x / hist) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
        else{
            hist = x;
        }

        if(hist > m){
            cout << 0 << endl;
            return 0;
        }
    }
    if(hist > m){
        cout << 0 << endl;
        return 0;
    }

    cout << (m - hist) / (2 * hist) + 1 << endl;



    return 0;
}


### FIXED CODE ###

import fractions
n,m = map(int,input().split())
l = input().split()
lcm = 1
sum = 0
for i in range(len(l)):
    lcm = (int(l[i]) * lcm) // fractions.gcd(int(l[i]), lcm)
for i in range(len(l)):
    if (lcm // int(l[i])) % 2 == 1:
        sum += 1
if sum == len(l):
    x = m // (int(lcm) // 2)
    y = m // lcm
    print(int(x - y))
else:
    print(0)
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    n, a, b = na()
    
    if a == 0 and b == 0 || a == 0:
        print(0)
        return

    if n <= a:
        print(n)
        return
      
    AB = a + b
    if n <= AB:
        print(min(n, a))
        return 
    
    x = int(n / AB)
    print(x * a + n - (x * AB))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    n, a, b = na()
    
    if (a == 0 and b == 0) or a == 0:
        print(0)
        return

    if n <= a:
        print(n)
        return
      
    AB = a + b
    if n <= AB:
        print(min(n, a))
        return 
    
    x = int(n / AB)

    print(x * a + min(n - (x * AB), a))

if __name__ == '__main__':
    main()
import math

A,B=map(int,input().split())

div=[]
for i in range(1,math.gcd(A,B)+1):
  if A%i==0 and B%i==0:
    div.append(i)

div.pop(0)
ans=1
val=1
for i in range(len(div)):
  if math.gcd(val,div[i])==1:
    ans+=1
    val*=div[i]
print(ans)

### FIXED CODE ###

def gcd(a,b): # 最大公約数を求める
  while b:
    a,b=b,a%b
  return abs(a)
  
def solve(A:int, B:int):
  a=gcd(A,B)
  ap=a
  ct=0
  x=2
  if a%x==0:
    ct+=1
    while a%x==0:
      a=a//x
  
  x=3
  while x*x<ap+1:
    if a%x==0:
      ct+=1
      while a%x==0:
        a=a//x
    x+=2
  
  if a!=1:
    ct+=1
  print(ct+1)
  
  return

def main():
  A,B=map(int,input().split())
  solve(A,B)

if __name__=="__main__":
  main()
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

for i in range(1, N):
    table[a[i]] = i

ans = [-1]*N
ans[0] = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] != i:
        ans[1] = a[0] ^ a[i]
        ans[2] = a[i]
        del(table[ans[1]])
        del(table[ans[2]])
        break
if ans[1] == -1:
    print("No")
    exit(0)

for i in range(3, N):
    if (ans[i-1] ^ ans[i-2]) in table and table[ans[i-1] ^ ans[i-2]] != i-2 and table[ans[i-1] ^ ans[i-2]] != i-1:
        ans[i] = ans[i-1] ^ ans[i-2]
        del(table[ans[i]])
    else:
        print("No")
        exit(0)
print("Yes")


### FIXED CODE ###

import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

for i in range(1, N):
    table[a[i]] += 1

ans = [-1]*N
ans[0] = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] >= 1:
        if a[0] == 0:
            if table[a[i]] == 1:
                continue
        ans[1] = (a[0] ^ a[i])
        ans[2] = a[i]
        table[ans[1]] -= 1
        table[ans[2]] -= 1
        break

if ans[1] == -1:
    print("No")
    exit(0)

for i in range(3, N):
    if (ans[i-1] ^ ans[i-2]) in table and table[ans[i-1] ^ ans[i-2]] >= 1 and table[ans[i-1] ^ ans[i-2]] >= 1:

        ans[i] = ans[i-1] ^ ans[i-2]
        table[ans[i]] -= 1
    else:
        print("No")
        exit(0)
print("Yes")
a = int(input())
b,c = map(int,input().split())
lis = input().split()

li = [int(l) for l in lis]

judge = True

d = 0

li.sort()

while judge:
    
    s = []
    s.append(min(li))
    li.remove(min(li))

    for n in li:
        if n >= b+1 and n<=c:
            s.append(n)
            li.remove(n)
            break
        else:judge = False

    for n in li:
        if n>=c+1:
            s.append(n)
            li.remove(n)
            break
        else:
            judge= False

    if len(s) == 3:
        d+=1
        judge = True
    else:judge=False

print(d)

### FIXED CODE ###

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

li = [int(l) for l in lis]

judge = True

d = 0

li.sort()

while judge:
    if li == []:
        break
    
    s = []
    for n in li:
        if n <= b:
            s.append(n)
            li.remove(n)
            break
        else:judge = False

    for n in li:
        if n >= b+1 and n<=c:
            s.append(n)
            li.remove(n)
            break
        else:judge = False

    for n in li:
        if n>=c+1:
            s.append(n)
            li.remove(n)
            break
        else:
            judge= False

    if len(s) == 3:
        d+=1
        judge = True
    else:judge=False

print(d)
from sys import exit
S = input()
T = input()
d = {}
for i in range(len(S)):
  if S[i] in d or T[i] in d:
    if d[S[i]] != T[i] or d[T[i]] != S[i]:
      print('No')
      exit()
  d[S[i]] = T[i]
  d[T[i]] = S[i]
print('Yes')


### FIXED CODE ###

S = input()
T = input()

d = {}
for i in range(len(S)):
  d[S[i]] = T[i]

t = []
for i in range(len(S)):
  t.append(d[S[i]])

if ''.join(t) != T or len(d.values()) != len(set(d.values())):
  print('No')
else:
  print('Yes')
X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y>=580000000000000000:
  print(0/0)
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)

### FIXED CODE ###

X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y==576460752303423487:
  print(59)
  exit()
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)
s = list(input())
t = list(input())
s.sort()
t.sort()

r = len(s) if len(s) < len(t) else len(t)
for i in range(0, r):
    if s.pop(i) == t.pop(i):
        continue
    elif s.pop(i) < t.pop(i):
        print("Yes")
        exit()
    else:
        print("No")
        exit()
print("Yes") if len(s) < len(t) else print("No")


### FIXED CODE ###

s = list(input())
t = list(input())
s.sort()
t.sort()
t.reverse()
print("Yes") if s < t else print("No")
a = input()
b = 700
for x in a:
	if x == "o":
    	b += 100
	else:
    	pass
print(b)
   

### FIXED CODE ###

a = input()
b = 700
for x in a:
    if x == "o":
       b += 100
    else:
        pass
print(b)
s=input()
a='abcdefghijklmnopqrstuvwxyz'
r='zyxwvutsrqponmlkjihgfedcba'
if len(s)!=26:
  for i in a:
    if i not in s:
      s=s+i
      break
elif s==r:
  s=-1
else:
  for i in range(25,0,-1):
    if i==1:
      s=chr(ord(s[0])+1)
      break
    if s[i]>s[i-1]:
      l=sorted(s[i:])
      for i in l:
        if i>s[i-1]:
          m=i
          break
      s=s[:i-1]+m
      break
print(s)

### FIXED CODE ###

s=input()
a='abcdefghijklmnopqrstuvwxyz'
r='zyxwvutsrqponmlkjihgfedcba'
if len(s)!=26:
  for i in a:
    if i not in s:
      s=s+i
      break
elif s==r:
  s=-1
else:
  for i in range(25,0,-1):
    if i==1:
      s=chr(ord(s[0])+1)
      break
    if s[i]>s[i-1]:
      l=sorted(s[i:])
      for j in l:
        if j>s[i-1]:
          m=j
          break
      s=s[:i-1]+m
      break
print(s)
a, b, c, d, e, k = map(int, input().split())
if e - a >= k:
  print(":(")
else:
  print("Yay!")

### FIXED CODE ###

import sys
a, b, c, d, e, k = map(int,sys.stdin.readlines())
if e - a > k:
  print(":(")
else:
  print("Yay!")
n=int(input())
    a=list(map(int,input().split(" ")))
    deta=[]
    error=False
     
    for i in range(n):
      if len(deta)==0:
        pass
      elif error:
        break
      elif a[i] in deta:
        error=True
      deta.append(a[i])
    if error:
      print("YES")
    else:
      print("NO")

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split(" ")))
deta = set()
error = False

for i in range(n):
    if n == 0:
        pass
    elif error:
        break
    elif a[i] in deta:
        error = True
        break
    deta.add(a[i])
if error:
    print("NO")
else:
    print("YES")
a,b = map(int,input().split())
if a*b % == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
print("Even" if a*b%2==0 else "Odd")
flag=True
for i in range(n):
    w.append(input())
    
for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:
        #print(i,"out1")
        flag=False

for i in range(n-1):
    for j in range(i+1,n):
        if(w[i]==w[j]):
            #print(i,j,"out2")
            flag=False

if flag==True:
    print("Yes")
else:
    print("No")




### FIXED CODE ###

n=int(input())
w=[]
flag=True
for i in range(n):
    w.append(input())
    
for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:
        #print(i,"out1")
        flag=False

for i in range(n-1):
    for j in range(i+1,n):
        if(w[i]==w[j]):
            #print(i,j,"out2")
            flag=False

if flag==True:
    print("Yes")
else:
    print("No")
from sys import setrecursionlimit

setrecursionlimit(10**6)

def dfs(i, depth):
    visited[i] = True
    oe = depth%2
    ans[i-1] = oe
    oe_index[oe] += [i]
    nodes = tree[i]
    for node in nodes:
        if visited[node]:
            continue
        dfs(node, depth+1)
    


N = int(input())
ans = [-1]*N
tree = [[] for i in range(N+1)]
visited = [False]*(N+1)
oe_index = [[], []]
base = [1, 2, 3]
for i in range(N-1):
    a, b = map(int, input().split())
    tree[a] += [b]
    tree[b] += [a]
dfs(1, 0)
even_len = len(oe_index[0])
odd_len = len(oe_index[1])
if even_len > N//3 and odd_len > N//3:
    for i, oe in enumerate(ans):
        if base[oe] > N:
            ans[i] = str(base[2])
            base[2] += 3
        else:
            ans[i] = str(base[oe])
            base[oe] += 3
elif even_len <= N//3:
    for i in oe_index[0]:
        ans[i] = str(base[2])
        base[2] += 3
    for i in oe_index[1]:
        if base[0] <= N:
            ans[i] = str(base[0])
            base[0] += 3
        else:
            ans[i] = str(base[1])
            base[1] += 3
elif odd_len <= N//3:
    for i in oe_index[1]:
        ans[i] = str(base[2])
        base[2] += 3
    for i in oe_index[0]:
        if base[0] <= N:
            ans[i] = str(base[0])
            base[0] += 3
        else:
            ans[i] = str(base[1])
            base[1] += 3
print(' '.join(ans))

### FIXED CODE ###

from sys import setrecursionlimit

setrecursionlimit(10**6)

def dfs(i, depth):
    visited[i] = True
    oe = depth%2
    ans[i-1] = oe
    count[oe] += 1
    nodes = tree[i]
    for node in nodes:
        if visited[node]:
            continue
        dfs(node, depth+1)
    


N = int(input())
ans = [-1]*N
tree = [[] for i in range(N+1)]
visited = [False]*(N+1)
count = [0, 0]
base = [1, 2, 3]
for i in range(N-1):
    a, b = map(int, input().split())
    tree[a] += [b]
    tree[b] += [a]
dfs(1, 0)
even_len = count[0]
odd_len = count[1]
if even_len > N//3 and odd_len > N//3:
    for i, oe in enumerate(ans):
        if base[oe] > N:
            ans[i] = str(base[2])
            base[2] += 3
        else:
            ans[i] = str(base[oe])
            base[oe] += 3
elif even_len <= N//3:
    for i, oe in enumerate(ans):
        if oe == 0:
            ans[i] = str(base[2])
            base[2] += 3
        elif base[0] <= N:
            ans[i] = str(base[0])
            base[0] += 3
        elif base[1] <= N:
            ans[i] = str(base[1])
            base[1] += 3
        else:
            ans[i] = str(base[2])
            base[2] += 3
elif odd_len <= N//3:
    for i, oe in enumerate(ans):
        if oe == 1:
            ans[i] = str(base[2])
            base[2] += 3
        elif base[0] <= N:
            ans[i] = str(base[0])
            base[0] += 3
        elif base[1] <= N:
            ans[i] = str(base[1])
            base[1] += 3
        else:
            ans[i] = str(base[2])
            base[2] += 3
print(' '.join(ans))
# 169 B

import math
n = int(input())
a = list(map(int, input().split()))
p = 1
x = True

p = math.product(a)
if p > (10 ** 18):
    x = False


if x == True:
    print(p)
else:
    print(-1)
        

### FIXED CODE ###

# 169 B

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

def code(a):
    pro = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            pro *= i
            if pro > (10 ** 18):
                print(-1)
                return
        print(pro)

code(l)
from collections import deque


def main():
    N, Q = map(int, input().split())
    ans = deque([0] * N)
    con = deque([[] for _ in range(N)])

    for _ in range(N - 1):
        p, c = map(int, input().split())
        con[p-1].append(c-1)
        con[c-1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1] += v

    stacks = deque()
    stacks.append((0, -1))

    while stacks:
        stack = stacks.pop()
        node, parent = stack[0], stack[1]

        children = con[node]
        for child in children:
            if child == parent:
                continue
            ans[child] += ans[node]
            stacks.append((child, node))

    print(*ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

n = int(input())
s = input()

if n >= 3200:
  print(s)
else:
  print('red')