Harryxun/stf_run huggingface dataset:
#二部グラフになっている時の色の塗り分けを聞いている
n=int(input())
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v,w])
  es[v-1].append([u,w])
  
colors=[0 for i in range(n)]
#深さ優先探索　頂点vをcolorで塗ることを考える
def dfs(v,color):
  colors[v-1]=color
  for i in es[v-1]:
    if i[1]%2==0 and colors[i[0]-1]==0:
      colors[i[0]-1]=color
      return dfs(i[0],color)
    elif i[1]%2==1 and colors[i[0]-1]==0:
      colors[i[0]-1]=-color
      return dfs(i[0],(-1)*color)

dfs(1,1)
for i in colors:
  if i==-1:
    print(0)
  else:
    print(1)
    
    
    
      
  


### FIXED CODE ###

# 再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)
#二部グラフになっている時の色の塗り分けを聞いている
n=int(input())
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v,w])
  es[v-1].append([u,w])

colors=[0 for i in range(n)]
#深さ優先探索　頂点vをcolorで塗ることを考える
def dfs(v,color):
  colors[v-1]=color
  for i in es[v-1]:
    if i[1]%2==0 and colors[i[0]-1]==0:
      dfs(i[0],color)
    elif i[1]%2==1 and colors[i[0]-1]==0:
      dfs(i[0],(-1)*color)
  return colors

    
a=dfs(1,-1)
for i in a:
  if i==-1:
    print(0)
  else:
    print(1)
def main():
    import bisect
    x,y,a,b,c = map(int,input().split())
    p = sorted(list(map(int,input().split())))
    q = sorted(list(map(int,input().split())))
    r = sorted(list(map(int,input().split())),reverse=True)
    ans = 0
    if x<=a:
        p = p[a-x:a]
    if y<=b:
        q = q[b-y:b]
    while True:
        if len(r)==0:
            break
        if p[0]>q[0]:
            if q[0]<r[0]:
                bisect.insort_right(q,r.pop(0))
                q.pop(0)
            else:
                break
        else:
            if p[0]<r[0]:
                bisect.insort_right(p,r.pop(0))
                q.pop(0)
            else:
                break
    print(sum(p)+sum(q))
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    import bisect
    x,y,a,b,c = map(int,input().split())
    p = sorted(list(map(int,input().split())))
    q = sorted(list(map(int,input().split())))
    r = list(map(int,input().split()))
    ans = 0
    if x<=a:
        p = p[a-x:a]
    if y<=b:
        q = q[b-y:b]
    ans = sorted(p+q+r,reverse=True)
    print(sum(ans[0:x+y]))
if __name__ == "__main__":
    main()
s = input()

s = s.split(" ")

x1 = int(s[0])
y1 = int(s[1])

x2 = int(s[2])
y2 = int(s[3])

 # X1 - X2 の増加量
zouka_x = abs(int(x1) - int(x2))

 # Y1 - Y2 の増加量
zouka_y = abs(int(y1) - int(y2))



if (x1 <= x2 and y1 <= y2):
    x3 = x2 - zouka_y
    y3 = y2 + zouka_x

    x4 = x1 - zouka_y
    y4 = y1 + zouka_x
elif (x1 > x2 and y1 < y2):
    x3 = x2 - zouka_y
    y3 = y2 - zouka_x

    x4 = x1 - zouka_y
    y4 = y1 - zouka_x
elif (x1 < x2 and y1 < y2):
    x3 = x2 - zouka_y
    y3 = y2 + zouka_x

    x4 = x1 - zouka_y
    y4 = y1 + zouka_x
elif (x1 < x2 and y1 > y2):
    x3 = x2 + zouka_y
    y3 = y2 + zouka_x

    x4 = x1 + zouka_y
    y4 = y1 + zouka_x

print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))


### FIXED CODE ###

x1, y1, x2, y2 = map(int, input().split())
 
vector_x, vector_y = x2 - x1, y2 - y1
print(x2 - vector_y, y2 + vector_x, x1 - vector_y, y1 + vector_x)
n, *l = map(int, open(0).read().split())

a = 1
for i in l:
	a *= i
	if a > 1e18:
		a =-1
		break
ptint(a)

### FIXED CODE ###

A, B = map(int, input().split())
print(A * B)
import sys

n= int(input())
a = list(map(int,input().split()))
ans = a[0]
ans_max = 10 ** 18

for i in range(1, n):
    ans *= a[i]
    if ans > ans_max:
        print("-1")
        sys.exit()

print(ans)

### FIXED CODE ###

a, b= input().split()

print(int(a) * int(b))
X = int(input())
	if X==3 or X==5 or X==7:
    	print('Yes')
    else:
    	print('No')

### FIXED CODE ###

X = int(input())

if X==3 or X==5 or X==7:
	print('YES')
else:
  	print('NO')
a.b.h= [int(input()) for i in range(3)]
print(int((a+b)*h/2))

### FIXED CODE ###

a,b,h= [int(input()) for i in range(3)]
print(int((a+b)*h/2))
import math
HL,ML,h,m=(int(x) for x in input().split())
HW=int((60*h+m)/2)
MW=int(6*m)

if HW >= MW:
    if HW-MW>180:
        w=360-(HW-MW)
    else:
        w=HW-MW
    print(math.sqrt(HL*HL+ML*ML-2*HL*ML*math.cos(math.radians(w))))
else:
    if HW-MW>180:
        w=360-(HW-MW)
    else:
        w=HW-MW
    print(math.sqrt(HL*HL+ML*ML-2*HL*ML*math.cos(mthradians(-w))))

### FIXED CODE ###

import math
HL,ML,h,m=(int(x) for x in input().split())
HW=float((60*h+m)/2)
MW=float(6*m)

if HW > MW:
    if HW-MW>180:
        w=360-(HW-MW)
    else:
        w=HW-MW
    print(math.sqrt(HL*HL+ML*ML-2*HL*ML*math.cos(math.radians(w))))
else:
    if HW-MW>180:
        w=360-(HW-MW)
    else:
        w=HW-MW
    print(math.sqrt(HL*HL+ML*ML-2*HL*ML*math.cos(math.radians(-w))))
O=list(input())
E=list(input())
F=[]
j=0
k=0
F=[0]*(len(O)+len(E))

while j<(len(O)+len(E)):
    F[j]=E[k]
    j=j+2
    k=k+1
j=1 
k=0
while j<(len(O)+len(E)):
    F[j]=O[k]
    j=j+2
    k=k+1 
F= ''.join([str(elem) for elem in F])
print(F)

### FIXED CODE ###

a = input()
b = input()

if(len(a) > len(b)):
    for i in range(len(b)):
        print(a[i],b[i],sep="",end="")
    print(a[i+1:])
else:
    for i in range(len(a)):
        print(a[i],b[i],sep="",end="")
    print(b[i+1:])
from collections import defaultdict


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

g = defaultdict(list)
for _ in range(m):
    l, r, d = map(int, input().split())
    g[l].append((r, d))
    g[r].append((l, -d))


checked = {}
ds = defaultdict(int)


def check(v):
    for next_v, d in g[v]:
        if not (next_v in ds):
            ds[next_v] = ds[v] + d
            if check(next_v) is False:
                return False
        elif not (ds[next_v] - ds[v] == d):
            return False
    return True


valid = True
for v in range(1, n + 1):
    if (not (v in ds)):
        ds[v] = 0
    if check(v):
        valid = False
        break

if valid:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import sys

sys.setrecursionlimit(200002)

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

g = [[] for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    g[l].append((r, d))
    g[r].append((l, -d))


ds = [None for _ in range(n + 1)]


def check(v):
    for next_v, d in g[v]:
        if ds[next_v] is None:
            ds[next_v] = ds[v] + d
            if check(next_v) is False:
                return False
        elif not (ds[next_v] - ds[v] == d):
            return False
    return True


valid = True
for v in range(n):
    if ds[v] is None:
        ds[v] = 0
    if check(v) is False:
        valid = False
        break

if valid:
    print("Yes")
else:
    print("No")
n = int(input())
w = [0]*n
for i in range(n):
  w[i] = map(int,input().split())
ans = float('inf')
for j in range(n):
  ans = min(ans,abs(sum(w[0:i]-w[i:n])))
print(ans)

### FIXED CODE ###

n = int(input())
w = list(map(int,input().split()))
ans = float('inf')
for j in range(n):
  ans = min(ans,abs(sum(w[0:j])-sum(w[j:n])))
print(ans)
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, sX, mod = mapint()

X = sX
s = set()
s.add(X)
s_loop = set()
ans = X
loop = 0
loops = []
for i in range(min(10**5*2+10, N-1)):
    X = pow(X, 2, mod)
    if X in s:
        if X in s_loop:
            loops.append(X)
            break
        loop += X
        s_loop.add(X)
        loops.append(X)
    s.add(X)
    ans += X

rest = N-i-2
if rest:
    ans += (rest//len(s_loop))*loop
    amari = rest%len(s_loop)+1
    for i in range(amari):
        ans += loops[i]
    print(ans)
else:
    print(ans)

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, sX, mod = mapint()

X = sX
s = set()
s.add(X)
s_loop = set()
ans = X
loop = 0
loops = []
i = -1
for i in range(min(10**5*2+10, N-1)):
    X = pow(X, 2, mod)
    if X in s:
        if X in s_loop:
            loops.append(X)
            break
        loop += X
        s_loop.add(X)
        loops.append(X)
    s.add(X)
    ans += X

rest = N-i-2
if rest:
    ans += (rest//len(s_loop))*loop
    amari = rest%len(s_loop)+1
    for i in range(amari):
        ans += loops[i]
    print(ans)
else:
    print(ans)
N = int(input())
a = [int(_) for _ in input().split()]

floor = math.floor(sum(a) / len(a))
ceil = math.ceil(sum(a) / len(a))

ceil_sum = sum([(item - ceil) ** 2 for item in a])
floor_sum = sum([(item - floor) ** 2 for item in a])

print(min(ceil_sum, floor_sum, median_sum))

### FIXED CODE ###

import math
N = int(input())
a = [int(_) for _ in input().split()]

floor = math.floor(sum(a) / len(a))
ceil = math.ceil(sum(a) / len(a))

ceil_sum = sum([(item - ceil) ** 2 for item in a])
floor_sum = sum([(item - floor) ** 2 for item in a])

print(min(ceil_sum, floor_sum))
N = int(input())
edges = [[] for _ in range(N)]
cnt_edges = [0]*N
colors = [0]*(N*(10**5)+10)
A = []
K = 0
for i in range(N-1):
    a,b = [int(x) for x in input().split()]
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

    cnt_edges[a-1]+=1
    cnt_edges[b-1]+=1
    A.append((a-1,b-1))
#%%
K = max(cnt_edges)

stk = [(0,0)]
seen = set()
while(stk):
    n,used_color = stk.pop()
    available_color = [i for i in range(1,K+1)]
    if(used_color!=0):
        available_color.remove(used_color)
    next_stk = []
    for next in edges[n]:
        if(next in seen):
            continue
        col = available_color.pop()
        next_stk.append((next,col))

        colors[next*(10**5)+n] = col
        colors[n*(10**5)+next] = col
    stk = next_stk + stk
    seen.add(n)

print(K)
for edge in A:
    a,b = edge
    col = colors[a*(10**5)+b]
    print(col)


### FIXED CODE ###

N = int(input())
edges = [[] for _ in range(N)]
cnt_edges = [0]*N
colors = [0]*(N-1)
di = {}
A = []
K = 0
for i in range(N-1):
    a,b = [int(x) for x in input().split()]
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

    K=max(K,len(edges[a-1]),len(edges[b-1]))
    di[(a-1,b-1)] = i
    di[(b-1,a-1)] = i
    A.append((a-1,b-1))
#%%
#K = max(cnt_edges)

stk = [(0,0)]
seen = set()
while(stk):
    n,used_color = stk.pop()
    available_color = 1
    next_stk = []
    for next in edges[n]:
        if(next in seen):
            continue
        if(available_color == used_color):
            available_color += 1
        next_stk.append((next,available_color))
        i = di[(next,n)]
        colors[i] = available_color
        available_color += 1
    stk += next_stk
    seen.add(n)

print(K)
for col in colors:
    print(col)
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
X_subtraction = []
for i in range(len(X)-1):
    X_subtraction.append(X[i+1] - X[i])

if X_subtraction != []:
    for _ in range(N-1):
        X_subtraction.remove(max(X_subtraction))

print(sum(X_subtraction))

### FIXED CODE ###

N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
X_subtraction = []
for i in range(len(X)-1):
    X_subtraction.append(X[i+1] - X[i])

X_subtraction.sort(reverse=True)
del X_subtraction[0:N-1]

print(sum(X_subtraction))
import sys
sys.setrecursionlimit(10**5)
n , q = map(int, input().split())
r = [[]for i in range(n)]
s = [0]*n
v = [0]*n
for i in range(n-1):
    a , b = map(int, input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
for i in range(q):
    p , x = map(int, input().split())
    s[p-1]+=x

def dfs(now):
    v[now]=1
    for i in r[now]:
        if v[i]==0:
            s[i]+=s[now]
            dfs(i)
    return
dfs(0)
print(' '.join(list(map(str,s))))


### FIXED CODE ###

from collections import deque

n , q = map(int, input().split())
r = [[]for i in range(n)]
s = [0]*n
v = [0]*n
for i in range(n-1):
    a , b = map(int, input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
for i in range(q):
    p , x = map(int, input().split())
    s[p-1]+=x
d= deque()
d.append(0)
def bfs(now):
    v[now]=1
    while d:
        i = d.popleft()
        for j in r[i]:
            if v[j]==0:
                s[j]+=s[i]
                v[j]=1
                d.append(j)
    return
bfs(0)
print(' '.join(list(map(str,s))))
N = int(input())
N -= 1
alphabets = []
for i in range(26):
    alphabets.append(chr(ord('a') + i))

idx = 1
now = 26
while now <= N:
    now += 26 ** (idx + 1)
    idx += 1
idx -= 1
ans = []
while idx > 0:
    ans.append(alphabets[N // (26 ** idx) - 1])
    N %= 26 ** idx
    idx -= 1
ans.append(alphabets[N])
print(*ans, sep='')

### FIXED CODE ###

# [基本方針]
# コンプロでもやった進数変換の応用問題。今回は26進数変換を基本に考える。
# 1:aではなく、0:aを対応していると考える。そのため、26で割ったあまりを考える時、0:a、1:b,..., z:25と考えることができる。
# 計算量はO(logN)

N = int(input())
ans = ''
while N:
    # 1をaではなく、0をaに割り当てると考えるため、N-=1を行う。
    N -= 1

    # ここから下は基本的な進数変換と同じ
    alphabet = chr(ord('a') + N % 26)
    ans += alphabet
    N //= 26
    
# 文字列を反転させる
print(ans[::-1])
li = list(map(input().split()))
count = 0

for i in range(3):
    if li[i] == "a":
        count = count + 1

print(count)

### FIXED CODE ###

a = input()

count = 0

for i in range(3):
    temp = a[i]
    if temp == "1":
        count = count + 1

print(count)
import sys
import math
n = int(raw_input())

for i in range(n):
    dist = math.sqrt((yb - ya) **2 + (xb - xa) **2)
    if dist > (ra + rb):
        return 0
    elif abs(ra - rb) <= dist <= (ra + rb):
        return 1
    elif dist < abs(ra - rb):
	if ra > rb:
            return 2
        else:
            return -2

### FIXED CODE ###

import sys
import math
N = int(sys.stdin.readline().strip())
 
def calc(xa, ya, ra, xb, yb, rb):
    dist = math.sqrt((yb - ya) **2 + (xb - xa) **2)
    if dist > (ra + rb):
        return 0
    elif abs(ra - rb) <= dist <= (ra + rb):
        return 1
    elif dist < abs(ra - rb):
        if ra > rb:
            return 2
        else:
            return -2
 
for i in xrange(N):
    line = sys.stdin.readline().strip()
    xa, ya, ra, xb, yb, rb = map(float, line.split())
    print calc(xa, ya, ra, xb, yb, rb)
import numpy as np

n , m , x = map(int,input().split())
understand_list = [list(map(int,input().split()))]
for _ in range(n-1):
    understand_list.append(list(map(int,input().split())))

money_list = []
for i in range(2 ** n):
    buy_list = []
    money = 0
    for j in range(n):
        if ((i >> j) & 1):
            buy_list.append(understand_list[j])
            money += understand_list[j][0]

    if buy_list == []:
        continue
    buy_list = np.sum(buy_list, axis=0)
    if all([i >= x for i in buy_list]):
        money_list.append(buy_list[0])

if money_list == []:
    print(-1)
else:
    print(min(money_list))

### FIXED CODE ###

import numpy as np

n , m , x = map(int,input().split())
understand_list = [list(map(int,input().split()))]
for _ in range(n-1):
    understand_list.append(list(map(int,input().split())))

money_list = []
for i in range(1,2 ** n):
    buy_list = []
    money = 0
    for j in range(n):
        if ((i >> j) & 1):
            buy_list.append(understand_list[j])
            money += understand_list[j][0]

    buy_list = np.sum(buy_list, axis=0)
    if all([i >= x for i in buy_list[1:]]):
        money_list.append(buy_list[0])

if money_list == []:
    print(-1)
else:
    print(min(money_list))
a, b, c = [int(i) for i input().split()]
if a<b<c:
    print("yes")
else:
    print("no")

### FIXED CODE ###

a, b, c = [int(i) for i in input().split()]
if a < b < c:
    print("Yes")

else:
    print("No")
def main():
  a = int(input())
  b = input()
  l = b.split()
  ll = []
  for i in range(0,a * 2):
    str = (b[0] + b[1])[i::4]
    str1 += str
  print(str1)

if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  a = int(input())
  b = input()
  l = b.split()
  d = a * 2
  str1 = []
  s = "".join(i+j for i, j in zip(l[0],l[1]))
  print(s)
 
if __name__ == '__main__':
  main()
i=1
while 1
    x,y = map(int,input().split())
    n=[x,y]
    n.sort()
    print n
    i=i+1

### FIXED CODE ###

while 1:
  x,y = map(int,raw_input().split())
  if x==0 and y==0:
    break
  else:
    n=[x,y]
    n.sort()
    print n[0],n[1]
N = int(input())
if '7' in N:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = input()
if '7' in N:
  print("Yes")
else:
  print("No")
n = int(input())

a = [int(input()) for i in range(n)]
a_max = max(a)
a2 = a[:]
a2.remove(a_max)
a_second_max = max(a2)

for i in range(n):
    if a[i] == a_max:
        print(a_second_max)
    else:
        print(a_max)

### FIXED CODE ###

r = int(input())

print(3 * (r * r))
A,B,C = map(input().split())

if A == 5 and B == 5 and C == 7:
	print("Yes")
elif B == 5 and C == 5 and A == 7:
	print("Yes")
elif C == 5 and A == 5 and B == 7:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

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

if A == 5 and B == 5 and C == 7:
	print("YES")
elif B == 5 and C == 5 and A == 7:
	print("YES")
elif C == 5 and A == 5 and B == 7:
	print("YES")
else:
	print("NO")
def resolve():
    '''
    code here
    '''
    import collections
    N, K = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]

    bit_k = bin(K)[2:]

    telepo_list = collections.deque([A_list])

    for _ in range(len(bit_k)-1):
        temp_list = telepo_list[-1]
        new_telep = collections.deque([])
        for i in temp_list:
            new_telep.append(temp_list[i-1])

        telepo_list.append(new_telep)

    # print(telepo_list)

    goto = 1
    for i in range(len(bit_k)):
        temp_list = telepo_list.popleft()
        if ((K >> i) & 1): 
            goto = temp_list[goto -1]
            # print(i, goto)

    print(goto)

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    S = input()
    T = input()

    if len(T) == len(S) + 1 and S == T[:-1]:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    resolve()
N = int(input())
S = lst(input())

cnt = 0

for i in range(0,4):
  if S[i] == "A" and S[i+1] == "C" and S[i+2] == "C":
    cnt += 1
    
print(cnt)

### FIXED CODE ###

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

cnt = 0

for i in range(0,N-2):
  if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
    cnt += 1
    
print(cnt)
n=int(input())
a= list(map(int,input().split()))

#for i in a:
#i=0
b=[0]*(10**5)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1
t=max(b)
print(t)

### FIXED CODE ###

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

#for i in a:
#i=0
b=[0]*(10**5+10)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1

print(max(b))
S=input()
ans=0
for i in range(len(S)):
    cnt=0
    k=i
    while True:
        if S[k] in ["A","C","G","T"] and k<len(S):
            cnt+=1
            k+=1
        else:
            if cnt>ans:
                ans=cnt
            break
print(ans)

### FIXED CODE ###

S=input()
ans=0
for i in range(len(S)):
    cnt=0
    while True:
        if  i>=len(S):
            break
        elif S[i] not in ["A","C","G","T"]:
            break
        else:
            cnt+=1
            i+=1    
    if cnt>ans:
        ans=cnt
print(ans)
a = int(input())
b = int(input())

if a + b >= 10:
  print("error")
else:
  print(a+b)

### FIXED CODE ###

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

if a + b >= 10:
  print("error")
else:
  print(a+b)
print(chr(ord(input())+1))

### FIXED CODE ###

r = int(input())
g = int(input())
print(2*g-r)
import sys
input = sys.stdin.readline
from math import factorial

MAX_V = 10**9 + 7

from math import factorial


'''
def nCr(n, r):
    if n < r:
        return 0
    return factorial(n) // (factorial(n - r) * factorial(r))

'''
def nCr(n, r):
    numerator = 1
    denominator = 1

    p = r if r < n-r else n-r

    for i in reversed(range(n-p+1, n+1)):
        numerator *= i

    for i in reversed(range(1, p+1)):
        denominator *= i

    return int(numerator / denominator)


n, b_k = map(int, input().split())
r_k = n-b_k
spot = r_k+1

min_k = min(b_k, spot)

#for i in range(1, min_k+1):
for i in range(1, b_k+1):
    c = nCr(spot, i) * nCr(b_k-1, i-1)
    print(c % MAX_V)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from math import factorial

MAX_V = 10**9 + 7

from math import factorial


def nCr(n, r):
    if n < r:
        return 0
    return factorial(n) // (factorial(n - r) * factorial(r))

'''
def nCr(n, r):
    numerator = 1
    denominator = 1

    p = r if r < n-r else n-r

    for i in reversed(range(n-p+1, n+1)):
        numerator *= i

    for i in reversed(range(1, p+1)):
        denominator *= i

    return int(numerator / denominator)
'''

n, b_k = map(int, input().split())
r_k = n-b_k
spot = r_k+1

min_k = min(b_k, spot)

#for i in range(1, min_k+1):
for i in range(1, b_k+1):
    c = nCr(spot, i) * nCr(b_k-1, i-1)
    print(c % MAX_V)
import bisect,collections,itertools,math,numpy,string,sympy
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(a,b,c):
    if sympy.sqrt(a)+sympy.sqrt(b)-sympy.sqrt(c) < 0:
        return 'Yes'
    else:
        return 'No'
    
a,b,c = LI()
print(main(a,b,c))

### FIXED CODE ###

import bisect,collections,decimal,itertools,math,numpy,string
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(a,b,c):
    if c-a-b < 0:
        return 'No'
    if 4*a*b < (c-a-b)**2:
        return 'Yes'
    return'No'
    
a,b,c = LI()
print(main(a,b,c))
6
105 119 105 119 105 119

### FIXED CODE ###

n = int(input())

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

odd = [data[i] for i in range(0,n,2)]
even = [data[i] for i in range(1,n,2)]

odd_dict = dict({})
even_dict = dict({})

for i in range(n//2):
    if odd_dict.__contains__(odd[i]):
        odd_dict[odd[i]]+=1
    else:
        odd_dict[odd[i]] = 1
    if even_dict.__contains__(even[i]):
        even_dict[even[i]]+=1
    else:
        even_dict[even[i]] = 1

odd = sorted(odd_dict.items(), key=lambda d:d[1],reverse=True)
even = sorted(even_dict.items(), key=lambda d:d[1],reverse=True)

odd.append((0,0))
even.append((0,0))
if odd[0][0] == even[0][0]:
    print(min(n-odd[0][1]-even[1][1],n-odd[1][1]-even[0][1]))
else:
    print(n-odd[0][1]-even[0][1])
import numpy as np
n = int(input())
b = np.array(list(map(int, input().strip().split())))
b *= 2
A = np.zeros((n,n))
for i in range(n):
    if i == n - 1:
        A[i,0] = 1
        A[i,n-1] = 1
    else:
        A[i,i] = 1
        A[i,i+1] = 1

#Ainv = np.linalg.inv(A)
#x = np.dot(Ainv, b)

x = np.linalg.solve(A, b)

s = str(x.astype(int))
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
print(s)

### FIXED CODE ###

import numpy as np
n = int(input())
b = list(map(int, input().strip().split()))
s = sum(b)
x = np.zeros((n))

x[0] = s
k = 1
for i in range(int((n-1)/2)):
    x[0] -= 2*b[k%n]
    k += 2

for i in range(1,n):
    x[i] = 2 * b[i-1] - x[i-1]

x = (x.astype(int)).tolist()

s = str(x)
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
s = s.replace('  ',' ')

print(s)
import sys
sys.setrecursionlimit(4100000)
N,K=map(int, input().split())
p=list(map(int, input().split()))
kitai=[0]*N
kitaiwa=[0]*(N-K+1)
for i in range(N):
    kitai[i]=(p[i]+1)/2
if N==K:
    print(sum(kitai))
elif K==1:
    print(max(kitai))
else:
    for i in range(N-K+1):
        for j in range(K):
            kitaiwa[i]+=kitai[i+j]
    print(max(kitaiwa))

### FIXED CODE ###

S,T=map(str, input().split())
A,B=map(int, input().split())
U=input()

if U==S:
    print(A-1,B)
else:
    print(A,B-1)