Harryxun/stf_run huggingface dataset:
n=int(input())
s=input()
s=list(s)
for i in range(len(s)):
    a=ord(s[i])+n
    if a>90:
        a-=26
    s[i]=chr(a)
print(''.join(s))

### FIXED CODE ###

s=input()
a={
'SUN':0,
'MON':1,
'TUE':2,
'WED':3,
'THU':4,
'FRI':5,
'SAT':6
}
print(7-a[s])
def reflesh_string(current_answer):
    index = min(K, len(current_answer))
    return current_answer[:index]

def update_string(string_answer):
    string_answer = string_answer.replace("1", "1")
    string_answer = string_answer.replace("2", "22")
    string_answer = string_answer.replace("3", "333")
    string_answer = string_answer.replace("4", "4444")
    string_answer = string_answer.replace("5", "55555")
    string_answer = string_answer.replace("6", "666666")
    string_answer = string_answer.replace("7", "7777777")
    string_answer = string_answer.replace("8", "88888888")
    string_answer = string_answer.replace("9", "999999999")
    return string_answer
  
def check_skip(current_answer):
    counter = [0 for i in range(9)]
    for k in range(min(K, len(current_answer))):
        counter[int(current_answer[k])] = 1
    if(sum(counter) == 1):
        return True
    
    if(sum(counter) == 2 and current_answer[min(K, len(current_answer)) - 1] != "1"):
        return True
    
    return False
    
S = input().strip()
K = int(input().strip())
for c in range(5 * 10**15):
    S = update_string(S)
    S = reflesh_string(S)
    if(check_skip(S)):
        break
print(S[min(K, len(S)) - 1])

### FIXED CODE ###

S = input().strip()
K = int(input().strip())

ans = 1
for i in range(min(K, len(S))):
    if(S[i] != "1"):
        ans = S[i]
        break
        
print(ans)
N=int(input())
h=[0 for i in n+1]
h=map(int,input().split())



### FIXED CODE ###

N=int(input())
h=[0 for i in range(N+1)]
h=list(map(int,input().split()))
dp=[0 for i in range(N+1)]
for i in range(1,N):
  if(i==1):
    dp[i]=dp[i]+abs(h[i]-h[i-1])
  else:
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])
n=int(intput())
if 30<=n:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n=int(input())
if 30<=n:
    print("Yes")
else:
    print("No")
a,b,c,d =map(int, input().split())
if abs(a-c)<=d:
  print("Yes")
  return
if a<=b<=c or c<=b<=a:
  if abs(a-b)<=d and abs(c-b)<=d:
    print("Yes")
    return
print("No")

### FIXED CODE ###

a,b,c,d =map(int, input().split())
ans="No"
if abs(a-c)<=d:
  ans ="Yes"
if a<=b<=c or c<=b<=a:
  if abs(a-b)<=d and abs(c-b)<=d:
    ans="Yes"
print(ans)
S = input().split()

if S == "ABC":
    print("ARC")
if s == "ARC":
    print("ARC")


### FIXED CODE ###

s = input()
if s[1] == "B":
    print("ARC")
else:
    print("ABC")
s=list(input())
if s[3]=s[2] and s[5]=s[4]:
print('Yes')
else:
print('No')

### FIXED CODE ###

s=list(input())
if s[3]==s[2] and s[5]==s[4]:
	print('Yes')
else:
	print('No')
n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
br=0
bw=0
for i in range(n):
    while(cl[wi] == "R" and bw==0):
        wi+=1
        if(wi >= n-1):
            bw=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    wi+=1
    if(wi >= n-1):
        wi=0
        bw=1
    while(cl[ri] == "W" and br==0):
        ri-=1
        if(ri <= 0):
            br=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        br=1
    #print(wi, ri)
    if(ri < wi):
        res1 = i+1
    if(br*bw==1):
        break
print(min(res1, rnum, wnum))

### FIXED CODE ###

n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
br=0
bw=0
res1 = n
break1 = 0
for i in range(n):
    while(cl[wi] == "R" and bw==0):
        wi+=1
        if(wi >= n-1):
            bw=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    while(cl[ri] == "W" and br==0):
        ri-=1
        if(ri <= 0):
            br=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    if(ri < wi and break1 == 0):
        res1 = i
        break1 = 1
    wi+=1
    if(wi >= n-1):
        wi=0
        bw=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        br=1

    if(br*bw==1):
        break
print(min(res1, rnum, wnum))
n = int(input())
if n == 1:
    print(0)
else:
    print(sum(list(range(1, n))))

### FIXED CODE ###

n = int(input())
print(n * (n-1)//2)
A,B,C,K= map(int, input().split())

if (A-B) ** 2 **0.5 > 10e18:
 print("Unfair")
elif K % 2 == 1:
 print(A-B)
else:
 print(B-A)


### FIXED CODE ###

A,B,C,K= map(int, input().split())
 
if (A-B) > 10e18 or (B-A) > 10e18:
 print("Unfair")
elif K % 2 == 1:
 print(B-A)
else:
 print(A-B)
def fun(n, y):
    for i in range(y//10000+1):
        for j in range((y - 10000*i)//5000+1):
            k = (y - 10000*i - 5000*j)//1000
            if i + j + k == n:
                print(i, j, k)
                break

    print(-1, -1, -1)

fun(n, y)

### FIXED CODE ###

n, y = map(int, input().split())
flag = False
for i in range(int(y/10000)+1):
    for j in range(int((y-i*10000)/5000)+1):
        k = n - i - j
        if i*10000 + j*5000 + k*1000 == y:
            print(i, j, k)
            flag = True
            break
    if flag:
        break
if not flag:
    print(-1, -1, -1)
def f(A, i, j, k, nex,res):
    if A[i] == A[j] == 0:
        print("No")
        exit()
    elif A[i] == A[j] == 1 and A[k] == 0:
        if i in nex:
            A[i] += 1
            A[j] -= 1
            return "ABC"[i]
        else:
            A[i] -= 1
            A[j] += 1
            return "ABC"[j]
    else:
        A[i] += 1
        A[j] -= 1
        return "ABC"[i]
    

def main():
    N, A, B, C = [int(_n) for _n in input().split()]
    S = []
    for i in range(N):
        s = input()
        S.append(s)
    if [A,B,C].count(0) == 3:
        print("No")
        return
    res = ""
    arr = [A,B,C]
    S.append("")
    for i,s in enumerate(S[:-1]):
        if S[i+1] == "AB":
            n = [0,1]
        if S[i+1] == "BC":
            n = [2,1]
        if S[i+1] == "AC":
            n = [0,2]
        if s == "AB":
            if arr[0] > arr[1]:
                res += f(arr, 1, 0, 2, n,res)
            else:
                res += f(arr,0,1,2,n,res)
        elif s == "BC":
            if arr[1] > arr[2]:
                res += f(arr, 2, 1, 0, n,res)
            else:
                res += f(arr,1,2,0,n,res)
        elif s == "AC":
            if arr[0] > arr[2]:
                res += f(arr, 2,0, 1, n,res)
            else:
                res += f(arr,0,2,1,n,res)
    for s in res:
        print(s)
main()

### FIXED CODE ###

def f(A, i, j, k, nex,res):
    if A[i] == A[j] == 0:
        print("No")
        exit()
    elif A[i] == A[j] == 1 and A[k] == 0:
        if i in nex:
            A[i] += 1
            A[j] -= 1
            return "ABC"[i]
        else:
            A[i] -= 1
            A[j] += 1
            return "ABC"[j]
    else:
        A[i] += 1
        A[j] -= 1
        return "ABC"[i]
    

def main():
    N, A, B, C = [int(_n) for _n in input().split()]
    S = []
    for i in range(N):
        s = input()
        S.append(s)
    if [A,B,C].count(0) == 3:
        print("No")
        return
    res = ""
    arr = [A,B,C]
    S.append("")
    for i,s in enumerate(S[:-1]):
        n = []
        if S[i+1] == "AB":
            n = [0,1]
        if S[i+1] == "BC":
            n = [2,1]
        if S[i+1] == "AC":
            n = [0,2]
        if s == "AB":
            if arr[0] > arr[1]:
                res += f(arr, 1, 0, 2, n,res)
            else:
                res += f(arr,0,1,2,n,res)
        elif s == "BC":
            if arr[1] > arr[2]:
                res += f(arr, 2, 1, 0, n,res)
            else:
                res += f(arr,1,2,0,n,res)
        elif s == "AC":
            if arr[0] > arr[2]:
                res += f(arr, 2,0, 1, n,res)
            else:
                res += f(arr,0,2,1,n,res)
    print("Yes")
    for s in res:
        print(s)
main()
n = int(input())
s = input()
c = 0

for i in range(1,n):
  s1 = set(s[:i])
  s2 = set(s[i:])
  w = lin(s1&s2)
  if w > c:
    c = w
    
print(c)

### FIXED CODE ###

n = int(input())
s = input()
c = 0
tmp = 0

for i in range(1,n):
  s1 = list(set(s[:i]))
  s2 = list(set(s[i:]))
  for j in s1:
    if j in s2:
      tmp += 1
  if tmp > c:
    c = tmp
  tmp = 0
  
print(c)
N=int(input())
H=list(map(int,input().split()))
count=0
if len(H)==1:
    print("Yes")
elif len(H)==2:
    if H[0]<=H[1]+1:
        print("Yes")
    else:
        print("No")
elif H[0]<=H[1]+1:
    for i in range(1,N-1):
        if H[i]<=H[i+1]:
            count+=1
            continue
        elif H[i]==H[i+1]+1:
            H[i]-=1
            if H[i]<H[i-1]:
                print("No")
                break
            else:
                count+=1
                continue
        else:
            print("No")
            break
else:
    print("No")
if count==N-2:
    print("Yes")

### FIXED CODE ###

a,b,c=map(int,input().split())
print(b+c-a if b+c-a>=0 else 0)
N,u,v = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N-1)]
    
x = [[] for _ in range(N)]
for ab in AB:
  a = ab[0]
  b = ab[1]
  x[a-1].append(b-1)
  x[b-1].append(a-1)
  
flag1 = [False]*N
flag2 = [False]*N
length1 = [0]*N
length2 = [0]*N
go = [v-1]
while go!=[]:
  a = go.pop()
  if flag1[a]:
    continue
  else:
    flag1[a]=True
    for i in x[a]:
      if flag1[i]:
        continue
      else:
        length1[i]=length1[a]+1
        go.append(i)

go = [u-1]
while go!=[]:
  a = go.pop()
  if flag2[a]:
    continue
  else:
    flag2[a]=True
    for i in x[a]:
      if flag2[i]:
        continue
      else:
        length2[i]=length2[a]+1
        go.append(i)
        
print(max(length1))

### FIXED CODE ###

A = int(input())
B = int(input())
l = [1,2,3]
l.remove(A)
l.remove(B)
print(l[0])
n,m = list(map(int,input().split()))
ans = [-1] * n

if n == 1 and m == 0:
  print(0)
  
for i in range(m):
  s,c = list(map(int,input().split()))
  if ans[s-1] != -1 and ans[s-1] != c:
    print(-1)
    exit()
  
  else:
    ans[s-1] = c

if ans.count(-1) >= 2:
  print(-1)
  exit()
  
elif ans[0] == 0 and n >= 2:
  print(-1)
  exit()
  
elif ans[0] == -1:
    ans[0] = 1
    
elif ans[1] == -1:
  if n == 2:
    ans[1] = 1
  else:
    ans[1] = 0
    
elif ans[2] == -1:
  ans[2] = 0
  

total = ans[2] + ans[1] * 10 + ans[0] * 100

print(total)

### FIXED CODE ###

n,m = list(map(int,input().split()))
ans = [-1] * n
total = 0
  
for i in range(m):
  s,c = list(map(int,input().split()))
  if ans[s-1] != -1 and ans[s-1] != c:
    print(-1)
    exit()
  
  else:
    ans[s-1] = c
  
if ans[0] == 0 and n >= 2:
  print(-1)
  exit()
  
elif ans[0] == -1 and n >= 2:
  ans[0] = 1
  
for i in range(n):
  if ans[i] == -1:
    ans[i] = 0
    
a = 0  
for i in range(n-1, -1, -1):
  total += ans[i] * 10**a
  a += 1

print(total)
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break
print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))
print(ans[0][19])

### FIXED CODE ###

#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)
if len(l) >= 2:
    for i in range(len(l)-1):
        ans = []
        for cx in range(101):
            for cy in range(101):
                if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy) and l[i][2] != 0 and l[i+1][2] != 0:
                    if i == 0:
                        ans.append([cx, cy])
                    else:
                        if [cx, cy] in ansn:
                            ans.append([cx, cy])
        ansn = ans[:]
        if len(ans) == 1:
            break
    print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))
else:
    print(l[0][0], l[0][1], l[0][2])
print(int(input)**3)


### FIXED CODE ###

print(int(input())**3)
import sys
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*('+X='not in e)or('=X'in e):]:
  l,r=e.replace('X',i).split('=')
  if sum(map(int,l.split('+')))==int(r):print(i);break
 else:print('NA')


### FIXED CODE ###

import sys
p,t='+X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!=p)or('+X'in e)*('+X='not in e):]:
  l,r=e.replace(t,i).split('=')
  if sum(map(int,l.split(p)))==int(r):print(i);break
 else:print('NA')
t = input()
s = list(t)
k = int(input())

ans = 0

s = s+s
for i in range(1,len(s)):
  if s[i-1] == s[i]:
    s[i] = "0"
    if i>=len(s)//2:
      ans += k-1
    else:
      ans += 1
      
if len(set(list(t))) == 1 and len(t)%2 == 1:
  ans = len(t) * (k//2) + (k%2==1)*(t//2)
print(ans)

### FIXED CODE ###

t = input()
s = list(t)
k = int(input())

ans = 0

s = s+s
for i in range(1,len(s)):
  if s[i-1] == s[i]:
    s[i] = "0"
    if i>=len(s)//2:
      ans += k-1
    else:
      ans += 1
      
if len(set(list(t))) == 1 and len(t)%2 == 1:
  ans = len(t) * (k//2) + (k%2==1)*(len(t)//2)
print(ans)
import math

from functools import lru_cache


# from decimal import Decimal, ROUND_HALF_UP
# def quantize(f):
#     return int(Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))


@lru_cache(maxsize=4096)
def get_cost(x, y):
    return int(math.pow(x - y, 2))


def get_costs(target, numbers):
    return sum([get_cost(target, n) for n in numbers])


def check(n, numbers):
    n_max = max(numbers)
    n_min = min(numbers)
    costs = []
    for target in range(n_min, n_max + 1):
        costs.append(get_costs(target=target, numbers=numbers))

    return min(costs)


def main():
    N = int(input())
    numbers = map(int, input().split())
    print(check(n=N, numbers=numbers))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math

from functools import lru_cache


@lru_cache(maxsize=4096)
def get_cost(x, y):
    return int(math.pow((x - y), 2))


def get_costs(target, numbers):
    return sum([get_cost(target, n) for n in numbers])


def check(n, numbers):
    n_max = max(numbers)
    n_min = min(numbers)
    costs = []
    for target in range(n_min, n_max + 1):
        costs.append(get_costs(target=target, numbers=numbers))

    return min(costs)


def main():
    N = int(input())
    numbers = list(map(int, input().split()))
    print(check(n=N, numbers=numbers))


if __name__ == '__main__':
    main()
n = input()
if n[-1] == 's':
    n+='es'
else:
    n+='s'
return n


### FIXED CODE ###

n = input()
if n[-1] == 's':
    n+='es'
else:
    n+='s'
print(n)
from collections import Counter
from typing import List, Set



def main()->None:
    # a_iに１を足すか、１引くか、何もしないかの操作を行って、ある整数個数最大化をする
    # x を決めるとgreedyに決まる。
    # 最後の一つのサンプルがTLEになる。jit の使い方もよくわからん
    N: int = int(input())
    a: List[int] = list(map(int, input().split()))
    set_a: Set[int] = set(a)
    max_count: int = 0
    top = 0
    for a_compo in set_a:
        X: int = a_compo
        tmp_count = 0
        for i in set_a:
            if abs(X - i) <= 1:
                tmp_count += a.count(i)
        if tmp_count > max_count:
            max_count = tmp_count

    print(max_count)

if __name__ == "__main__":
    main()
  

### FIXED CODE ###

import sys


def main()->None:
    N = int(sys.stdin.readline())
    a = list(map(int, sys.stdin.readline().split()))
    max_a = max(a)
    # print(max_a)
    l = [0 for _ in range(max_a+2)] # 配列の初期化、固定長、位置が配列の数字で要素がカウント
    for i in a:
        l[i] += 1
    res = 0
    for i in range(0, max_a+1):
        tmp = l[i-1]+l[i]+l[i+1]
        res = max(res, tmp)
    print(res)


if __name__ == "__main__":
    main()
n=int(input())
if n % 2 == 0:
  temp = int(n/2)
  print(temp ** 2)
elif:
  temp = n//2
  print(temp*(temp+1))

### FIXED CODE ###

n=int(input())
if n % 2 == 0:
  temp = int(n/2)
  print(temp ** 2)
else:
  temp = n//2
  print(temp*(temp+1))
from itertools import permutations
import copy

def dis(po1,po2):
  return(abs(po1[0]-po2[0])+abs(po1[1]-po2[1]))

def print_process(min_prm):
  for i in range(0,len(min_prm)//2+1,2):
    while prm[i][0] != prm[i+1][0]:
      prv_prm = copy.deepcopy(prm[i])
      if prm[i][0] < prm[i+1][0]: prm[i][0] += 1
      else: prm[i][0] -= 1
      print(*prv_prm + prm[i])
   
    while prm[i][1] != prm[i+1][1]:
      prv_prm = copy.deepcopy(prm[i])
      if prm[i][1] < prm[i+1][1]: prm[i][1] += 1
      else: prm[i][1] -= 1
      print(*prv_prm + prm[i])

H,W = map(int,input().split())
odds = []
for j in range(H):
  for i, a in enumerate(map(int,input().split())):
    if a%2 == 1:
      odds.append([i+1,j+1])

min_prm = None
min_dis = float('inf')
for prm in permutations(odds):
  tmp_dis = 0
  for i in range(0,len(prm)//2+1,2):
    tmp_dis += dis(prm[i],prm[i+1])
  
  if min_dis > tmp_dis:
    min_prm = prm
    min_dis = tmp_dis
print(min_dis)
print_process(min_prm)

### FIXED CODE ###

H,W = map(int,input().split())
A = [[0 for _ in range(W+1)]]
sumA = 0
for _ in range(H):
  row = [0] + list(map(int,input().split())) 
  A.append(row)
  sumA = sum(row)



c_num = 0
pros = []
for j in range(1,H+1):
  for i in range(1,W):
    if A[j][i]%2==1:
      pros.append([j,i, j,i+1])
      c_num += 1
      A[j][i] -= 1
      A[j][i+1] += 1
 
for j in range(H,1,-1):
  if A[j][W]%2==1:
    pros.append([j,W,j-1,W])
    c_num += 1
    A[j][W] -= 1
    A[j-1][W] += 1

print(c_num)
[print(*pro) for pro in pros]
#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
print(ans)
    

### FIXED CODE ###

#coding:UTF-8
num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1
#    print("i:{} count:{} max:{}".format(i,count,max))
  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
else:
  print(ans)
import sys
input = sys.stdin.readline

N = int(input())
X = [int(x) for x in input().split()]
MAX = max(X)
res = []
for a in range(1, int(MAX)):
  total = 0
  for x in X:
    kyori = (x - a) * (x - a)
    total += kyori
  res.append(total)
print(min(res))

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
X = [int(x) for x in input().split()]
P = int(sum(X) / N + 0.5)
total = 0
for x in X:
  kyori = (x - P) * (x - P)
  total += kyori
print(total)
import sys

n, y = input().split()
n = int(n)
y = int(y)

for a in range(n+1):
	for b in range(n+1):
		for c in range(n+1):
            if a + b + c < n:
              continue
            if a + b + c > n:
              break
			if (a + b + c == n) and (a * 10000 + b * 5000 + c * 1000 == y):
				print(str(a) + ' ' + str(b) + ' ' + str(c))
				sys.exit()

print('-1 -1 -1')

### FIXED CODE ###

import sys

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

for a in range(n+1):
	for b in range(n+1-a):
		c = n - a - b
		if (a * 10000 + b * 5000 + c * 1000 == y):
				print(str(a) + ' ' + str(b) + ' ' + str(c))
				sys.exit()
	
print('-1 -1 -1')
sys.exit()
S = list(input())
form = "0"+str(len(S)-1)+"b"
ans = 0
for i in range(2**(len(S)-1)):
    b = format(i, form)
    eq = [S[0]]
    for j in range(len(b)):
        if b[j] == "1":
            sign = "+"
        else: sign = ""
        eq.append(sign)
        eq.append(S[j+1])
    eqstr = str("".join(eq))
    ans += eval(eqstr)
print(ans)
        

### FIXED CODE ###

S = list(input())
form = "0"+str(len(S)-1)+"b"
ans = 0
if len(S)==1:
    print(int(S[0]))
else:
    for i in range(2**(len(S)-1)):
        b = format(i, form)
        eq = [S[0]]
        for j in range(len(b)):
            if b[j] == "1":
                sign = "+"
            else: sign = ""
            eq.append(sign)
            eq.append(S[j+1])
        eqstr = str("".join(eq))
        ans += eval(eqstr)
    print(ans)
N = int(input())

A = {}
B = []
C = [-1] * (N)

for _ in range(N - 1):
  u, v, w = map(int, input().strip().split(' '))
  if u not in A: A[u] = {}
  if v not in A: A[v] = {}

  for key, val in A[u].items():
    s = val + w
    A[v][key] = s
    A[key][v] = s
    if s % 2 == 1:
      B.append((v, key))

  for key, val in A[v].items():
    s = val + w
    A[u][key] = s
    A[key][u] = s
    if s % 2 == 1:
      B.append((u, key))

  A[u][v] = w
  A[v][u] = w
  if w % 2 == 1:
    B.append((u, v))

for k0, k1 in B:
  del A[k0][k1]
  del A[k1][k0]

k, v = A.popitem()
C[k - 1] = 0
for i in v.keys():
  C[i - 1] = 0
  del A[i]

for i in A.keys():
  C[i - 1] = 1

for i in C:
  print(i)

### FIXED CODE ###

from collections import deque

N = int(input())

A = {}
COLOR = [1] * N

for _ in range(N - 1):
  u, v, w = map(int, input().strip().split(' '))
  if u not in A: A[u] = {}
  if v not in A: A[v] = {}
  A[u][v] = w
  A[v][u] = w


def test(key, total_w=0):
  if key not in A:
    return

  COLOR[key - 1] = 0 if total_w % 2 == 0 else 1

  v = A.pop(key)
  for k, w in v.items():
    test(k, w + total_w)


queue = deque()
queue.append((1, 0))
current_key = 1

while len(queue) > 0:
  key, w = queue.popleft()
  if key not in A:
    continue

  COLOR[key - 1] = 0 if w % 2 == 0 else 1

  for child in A.pop(key).items():
    if child[0] in A:
      queue.append((child[0], w + child[1]))

for c in COLOR:
  print(c)
def binary_search(A, B, X):
    intial_N = 0
    end_N = 10**20
    while (end_N - intial_N > 1):
        mid_N = round((intial_N + end_N) / 2)
        digits = len(str(mid_N))
        temp_value = A*mid_N + B*digits
        if (temp_value > X):
            end_N = mid_N
        elif (temp == X):
            return mid_N
        else:
            intial_N = mid_N 
    return intial_N
            
A, B, X = map(int, input().split())
int_N = binary_search(A, B, X)
print(int_N)

### FIXED CODE ###

A = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
S = input()
cnt = 0
for i in range(7):
    if A[i] == S:
        break;
    cnt += 1
print(7 - cnt)
S = input()
checker = 0
for i in S:
    if i == o:
        checker += 1
sum = 700 + 100 * checker
print(sum)

### FIXED CODE ###


S = input()
checker = 0

for i in list(S):
    if i == 'o':
        checker += 1
sum = 700 + 100 * checker
print(sum)
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
ls = []
for _ in range(5):
    ls.append(int(input()))
if N <= min(ls):
    print(5)
    else:
        mint = min(ls)
        ans = 5 + min//N +1
        print(ans)

### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import math

N = int(input())
ls = []
for _ in range(5):
    ls.append(int(input()))

if N <= min(ls):
    print(5)
else:
    mint = min(ls)
    ans = 4 + math.ceil(N/mint) 
    print(ans)
# - coding : utf-8 -*-
 
n, m = input().split()
xs_str = input().split()
xs = list(map(int, xs_str))
xs.sort()
 
ys = []
for x1, x2 in zip(xs[0:-1], xs[1:]):
    ys.append(abs(x2 - x1))
ys.sort()
 
if len(ys) > n:
    out = sum(ys[0:-(n-1)])
else:
    out = 0
print(out)

### FIXED CODE ###

# - coding : utf-8 -*-
 
n, m = list(map(int, input().split()))
xs_str = input().split()
xs = list(map(int, xs_str))
xs.sort()
 
ys = []
for x1, x2 in zip(xs[0:-1], xs[1:]):
    ys.append(abs(x2 - x1))
ys.sort()

for i in range(n - 1):
    if ys == []:
        break
    else:
        ys.pop()
print(sum(ys))
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0

for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp(n-1))

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0

for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp[n-1])