peterverebics/CodeNet_Python_118 huggingface dataset:
from collections import Counter
N = int(input())
S = [str(input()) for i in range(N)]
S.sort()
li = Counter(S)
key,value = zip(*li.most_common())
value += (0,)
MAX = value[0]
print(key[0])

for i in range(1,N):
    if value[i]==MAX:
        print(key[i])
    else:
        break
# -*- coding: utf-8 -*-

N = int(input())
S = [input().strip() for _ in range(N)]

d = {}
for s in S:
    d.setdefault(s, 0)
    d[s] += 1

dmax = max(d.values())

for key, value in d.items():
    if value == dmax:
        print(key)
n=int(input())
poll=[input() for i in range(n)]

dic={}
for string in poll:
  if string not in dic:
    dic[string]=1
  else:
    dic[string]+=1

max_k=[k for k, v in dic.items() if v == max(dic.values())]
print(*max_k,sep='\n')
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = list(c.keys())
li.sort()
max = li[-1]
for i in ca:
    if c[i] == max:
        print(i)
n = int(input())
s = list(input() for _ in range(n))
d = {}
for i in range(n):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
m = max(d)
for i in sorted(d.keys()):
    if d[i] == d[m]:
        print(i)
n=int(input())
l=0
s=[]
for i in range(n):
    si=input()
    s.append(si)
    li=len(si)
    l=max(l,li)
ans=[]
for i in range(n):
    if len(s[i])==l:
        ans.append(s[i])

ans.sort()
for i in ans:
    print(i)
from collections import Counter
data = ['aaa', 'bbb', 'ccc', 'aaa', 'ddd']
counter = Counter(data)
print(counter.most_common()[0][0])
import collections
from collections import Counter
n=int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)
max = c.most_common()[0][1]
for i in c.items():
    if i[1] == max:
        print(i[0])
import collections
import sys

input = sys.stdin.readline

N = int(input())
candidate = [input().strip("\n") for _ in range(N)]

candidate.sort()
c = collections.Counter(candidate)

max = c.most_common()[0][1]

for i in range(len(c.most_common())):
    tmp, tmp2 = c.most_common()[i]
    if tmp2 == max:
        print(tmp)
        continue
    else:
        break
from collections import Counter
n = int(input())
s = list(input() for i in range(n))
s.sort()
counted = Counter(s)
m = max(counted.values())
chars = [key for key, value in counted.items() if value == m]

for i in range(len(chars)):
    print(chars[i])
N = int(input())
s = [input() for i in range(N)]
import collections
s1 = sorted(s)

c = collections.Counter(s1)
s2 = c.most_common()


a = 0
for i in range(len(s2)):
    if s2[0][1] == s2[i][1]:
        a = a + 1
    else:
        break

for j in range(a):
    print(str(s2[j][0]))
n = int(input())
dic = {}
maxim = 0
for i in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
        if dic[s] > maxim:
            maxim = dic[s]
        
dic2 = sorted(dic.items(), key=lambda x:x[1], reverse=True)

ll = []
for i in dic2:
    if i[1] != maxim:
        break
    else:
        ll.append(i[0])
for i in sorted(ll):
    print(i)
import collections
N = int(input())
S = [input() for _ in range(N)]
count = collections.Counter(S)
maxV = max(count.values())
c = [k for k, v in count.items() if v == maxV]
print('\n'.join(c))
from decimal import*
from fractions import*
import math
import functools


import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inputt = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines 

s,t=input().split()
a,b=input().split()
u=input()
if(u==s):
    a=int(a)-1
else:
    b=int(b)-1
print(a,end=" ")
print(b)
S,T = list(map(str,input().split()))
A,B = list(map(int,input().split()))
u = input()

if u == S:
  print(str(A-1) + " " +str(B))
else:
  print(str(A) + " " +str(B-1))
s,t = input().split()
a,b = (int(x) for x in input().split())
u = input()
if s == u:
	a-=1
else:
	b-=1
print(a,b)
s, t = input().split(" ")
a, b = (int(x) for x in input().split(" "))
u = input()
 
if s==u:
  print(a-1, b)
else:
  print(a, b-1)
S, T = input().split()
A, B = map(int, input().split())
U = input()

if S == U:
    print(A - 1, B)
else:
    print(A, B - 1)
s,t = input().split()
a,b = map(int,input().split())
u = input()

if u == s:
  print(a-1,b)
elif u == t:
  print(a,b-1)
else:
  print(a,b)
n, k=input().split()
l, m= map(int, input().split())
o = input()
if n==o:
	l = l-1
if k == o:
	m = m-1
print(l,m)
S,T = input().split()
A,B = input().split()
A = int(A)
B = int(B)
U = input()
if S == U:
    A -= 1
if T == U:
    B -= 1
print(A," ",B)
S,T = input().split()
A,B = map(int,input().split())
U = input()
count_S = U.count(S)
count_T = U.count(T)


S_amount = A - count_S
U_amount = B - count_T

print(S_amount,U_amount)
S, T = input().split()
A, B = map(int, input().split())
U = input()

Balls = {}
Balls[S] = A
Balls[T] = B
Balls[U] -= 1

print(Balls[S], Balls[T])
n, m = map(str, input().split())
a, b = map(int, input().split())
u = str(input())

if n==u:
  a=a-1
  
if m==u:
  b=b-1

print(a ,b)
S,T = input().split()
A,B = map(int,input().split())
U = input()
ans1 = A
ans2 = B
if S==U:
    ans1 -= 1
else:
    ans2 -= 1
print(ans1, ans2)
def main():
    s, t = list(input().split())
    a, b = list(map(int, input().split()))
    u = input()

    if u == s:
        a -= 1
    else:
        b -= 1
    print(a, b)

if __name__ == '__main__':
    main()
s,t = input().split()
a,b = map(int,input().split())
u = input()

if s == u:
    print(a-1,b)
else:
    print(a,b-1)
s, t = input().split()
a, b = map(int, input().split())
u = input()

if s == u:
    print(a-1, b)
else:
    print(a, b-1)
s,a,u=open(0);i=u in s;print(int(a[:2])-1+i,int(a[2:])-i)
s, t = input().split()
a, b = map(int, input().split())
u = input()

if u == s:
    print(a-1,b)
else: print(a,b-1)
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s :
    print( str(a-1) + " " + str(b))
elif u == t :
    print( str(a) + " " + str(b-1))
D = {}
s, t = input().split()
a, b = map(int, input().split())
D[s] = a
D[t] = b
D[input()] -= 1
print(D[s], D[t])
S,T = input().split()
A,B = map(int,input().split())
U = input()
if S==U:
    A -= 1
else:
    B -= 1
print(A,B)
s,t=input().split()
a,b=map(int,input().split())
u=input()
if u==s:
	a-=1
else:
	b-=1
print(a,b)
s,t = input().split()
a,b = map(int,input().split())
u = input()

if u==s:
    print(a-1,b)
else:
    print(a,b-1)
s,t=map(str,input().split())
a,b=map(int,input().split())
u=input()
if s==u:
    a-=1
if t==u:
    b-=1
print(a,b)
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    print(a-1, b)
else:
    print(a, b-1)
S,T = map(str,input().split())
A,B = map(int,input().split())
U = input()

if S==U: A -= 1
if T==U: B -= 1
  
print(str(A) + " " + str(B))
a, b = map(str, input().split())
n, m = map(int, input().split())
u = input()
if u == a:
    print(n - 1, m)
else:
    print(n, m - 1)
S, T = map(str, input().split())
A, B = map(int, input().split())
U = str(input())

if S == U:
  A -=1
elif T == U:
  B -=1

print(A, B)
#Macで実行する時
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../atcoder/input.txt'))
	sys.stdin = open(name)

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

if check == l[0]:
    a -= 1
else:
    b -= 1

print(a,b)
S, U = map(str, input().split())
s, u = map(int, input().split())
n = input()

if n == S:
    s -= 1
else:
    u -= 1

print(s, u)
import itertools
import math
import fractions
import functools
s, t = input().split()
a, b = map(int,input().split())
u = input()

if u == s:
    print(a-1,b)
else:
    print(a,b-1)
S,T = map(str,input().split())
A,B = map(int,input().split())
U = input()

if(S==U):
	A=A-1
elif(T==U):
	B=B-1
print(A,B)
s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()
if s == u:
  print(a - 1, b)
else:
  print(a, b - 1)
def main():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if s == u:
        print(a-1, b)
    else:
        print(a, b-1)


if __name__ == "__main__":
    main()
S,T=input().split()
A,B = map(int,input().split())
U = input()
ans = ""
if U==S:
    A=A-1
    a=str(A)
    b=str(B)
    ans = a+" "+b
    print(ans)
else:
    B-=1
    a=str(A)
    b=str(B)
    ans=a+" "+b
    print(ans)
a,b=[i for i in input().split()]
n,m=[int(i) for i in input().split()]
s=input()
if s == a:
  n-=1
else:
  m-=1
print(n,m)
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

s,t=s1()
a,b=n1()
u=s0()
if s==u:
    a=a-1
else:
    b=b-1
print(a,b)
from sys import stdin
A, B= stdin.readline().rstrip().split()
m = [A,B]
k = list(map(int, input().split()))
l = stdin.readline().rstrip().split()
k[m.index(l[0])] = k[m.index(l[0])] -1
print(k[0],k[1])
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

s, t = readline().decode('utf-8').split()
a, b = map(int, readline().split())
u = read().decode('utf-8').rstrip()

if u == s:
    a -= 1
else:
    b -= 1

print(a, b)
def solve():
    S,T = input().split()
    A,B = [int(i) for i in input().split()]
    U = input()

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

if __name__ == "__main__":
    solve()
S,T=map(str,input().split())
A,B=map(int,input().split())
U=str(input())
ans=""
if(U==S):
    ans=str(A-1)+" "+str(B)
else:
    ans=str(A)+" "+str(B-1)
print(ans)
S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if S == U:
  print(A - 1, B)
else:
  print(A, B -1)
S, T = input().split()
A, B = map( int, input().split() )
U    = input()

if( S==U ):
    A-=1
if( T==U ):
    B-=1

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

if U == S:
    A -=1
else:
    B -=1
print(str(A)+" "+str(B))
S, T = input().split()
A, B = map(int, input().split())
U = input()

if S == U:
    A -= 1
elif T == U:
    B -= 1

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

if U == S:
    A -= 1
else:
    B -= 1

print('{} {}'.format(A, B))
S,T = map(str,input().split())
A,B = map(int,input().split())
U = str(input())
if S == U:
    print(A-1,B)
else:
    print(A,B-1)
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)
S,T = input().split()
A,B = map(int,input().split())
U = input()

if S == U:
  A -= 1
else:
  B -= 1
  
print(A,B)
S, T = input().split()
A,B = map(int,input().split())
U = input()
if U == S:
  A -= 1
  print(A,B)
else:
  B -= 1
  print(A,B)
s, t = input().split()
a, b = map(int, input().split())
u = input()

if u == s:
    a -= 1

if u == t:
    b -= 1

print('%d %d' % (a, b))
s ,t= [x for x in input().split()]
A , B = [int(x) for x in input().split()]
U = input()
if s != t:
    if U == t :
        B -=1
    if U == s:
        A-= 1
print('{} {}'.format(A,B))
s,t=input().split()
a,b=map(int,input().split())
u=input()
ans=0
if u  in s:
  a-=1
if u in t:
  b-=1
print(a,b)
s, t = input().split()
a, b = map(int,input().split())
u = input()
if u == s:
    print(a-1, b)
else:
    print(a, b-1)
S,T=input().split()
A,B=map(int,input().split())
U=input()

if S==U:
  print(str(A-1) + " " + str(B))
else:
  print(str(A) + " " + str(B-1))
s, t = map(str, input().split())
a, b = map(int, input().split())
u = str(input())
if u == s:
    a -= 1
else :
    b -= 1
print (a, b)
s, t = input().split(" ")
a, b = map(int, input().split(" "))
u = input()
if u == s:
    a -= 1
else:
    b -= 1
print(a, b)
s, t = input().split()
a, b = map(int, input().split())
u = input()

if u == s:
    print(a - 1, b)
else:
    print(a, b - 1)
s,t=map(str,input().split())
a,b=map(int,input().split())
u=str(input())
print((a-1),b) if u==s else print(a,(b-1))
S,T=input().split()
#print(S)
A,B=map(int,input().split())

U=input()
if U==S:
    A-=1
else:
    B-=1
print(A,B)
T = input().split()
A = [int(a) for a in input().split()]
B = input()
if T[0] == B:
	print(A[0]-1,A[1])
else:
	print(A[0],A[1]-1)
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U==S:
    A = A - 1
else:
    B = B - 1

print("%d %d"%(A,B))
n=2
s=[""]*n
a=[0]*n
s[:]=input().split()
a[:]=map(int,input().split())
u=input()
for ii in range(n):
  if s[ii]==u:
    a[ii]-=1
    break
print(" ".join([str(ii) for ii in a]))
S, T = input().split();
A = list(map(int, input().split()));
U = input();

if U == S:
  A[0] = A[0] - 1;
elif U == T:
  A[1] = A[1] - 1;

print(A[0], A[1])
a, b = input().split()
A, B = map(int,input().split())
c = input()

if a == c:
    print(A - 1, B)
else:
    print(A, B - 1)
s1 = input().split()
s2= s1[1]
s1=s1[0]

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

if(s==s1):
	print(a-1,b)
else:
  	print(a,b-1)
import sys
from pprint import pprint

def solve(s, t, a, b, u):
    if u == s:
        a -= 1
    if u == t:
        b -= 1
    print(a, b)

if __name__ == '__main__':
    s, t = sys.stdin.readline().strip().split(" ")
    a, b = map(int, sys.stdin.readline().strip().split(" "))
    u = sys.stdin.readline().strip()
    solve(s, t, a, b, u)
a=list(map(str,input().split()))
b=list(map(int,input().split()))
b[a.index(input())]-=1
print(*b)
s, t = input().split()
x, y = map(int, input().split())
query = input()
if query == s:
    x -= 1
else:
    y -= 1
print("{} {}".format(x, y))
S, T = input().split()
A, B = map(int,input().split())
U = input()

dic = {}
dic[S] = A
dic[T] = B

dic[U] -= 1

print(dic[S],dic[T])
s,t=input().split()
x,y=map(int,input().split())
if s==input():
    print(x-1,y)
else:
    print(x,y-1)
s, t = map(str, input().split())
a, b = map(int, input().split())
u = str(input())

if u == s:
    print(a - 1, b)
elif u == t:
    print(a, b - 1)
s, t = input().split()
a, b = map(int, input().split())
u = input()

balls = {}

balls[s] = a
balls[t] = b

balls[u] = balls[u] - 1

print('{0} {1}'.format(balls[s], balls[t]))
col=list(map(str,input().split()))
num=list(map(int,input().split()))
U=str(input())
if U == col[0]:
  num[0] = num[0]-1
elif U == col[1]:
  num[1] = num[1]-1
[print(num[i],end=" ") for i in range(2)]
S, T = input().split()
A, B = map(int, input().split())
U = input()

if S == U:
    A -= 1
else:
    B -= 1

print(A, B)
S,T=input().split()
A,B=map(int,input().split())
U=input()
if S==U:
    print('{} {}'.format(A-1,B))
else:
    print('{} {}'.format(A,B-1))
S,T = list(map(str,input().split()))
A,B = list(map(int,input().split()))
U = input()

if S == U:
  A = A - 1
else:
  B = B - 1

print(A,' ',B,sep='')
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    A -= 1
else:
    B -= 1

print(f'{A} {B}')
S, T = input().split()
A, B = map(int, input().split())
U = input()

if S == U:
    A -= 1
else:
    B -= 1

print(A,B)
s, t = input().split(' ')
a, b = map(int, input().split())
u = input()
if s == u: a -= 1
if t == u: b -= 1
print(a, b)
s,t=map(str,input().split())
a,b=map(int,input().split())
u=input()

if s==u:
  print(a-1,b)
  
elif t==u:
  print(a,b-1)
#A
S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:
    A -= 1
else:
    B -= 1
print(A, B)
s,t=input().split()
a,b=input().split()
aa=int(a)
bb=int(b)
u=input()
if u==s:
    aa=aa-1
elif u==t:
    bb=bb-1
print(aa,"",bb)
s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()
if u == s:
    a -= 1
elif u == t:
    b -= 1
print(a, b)
S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if U == S:
  A -= 1
else:
  B -= 1

print(A, B)
s = list(input().split())
a = list(map(int, input().split()))
t = input()
a[s.index(t)] -= 1
print(*a)
S, T = [i for i in input().split()]
A, B = [int(i) for i in input().split()]
U = input()
if U == S:
    print(A-1, B)
else:
    print(A, B-1)
def q1():
    S,T = (s for s in input().split())
    A,B = (int(i) for i in input().split())
    U = input()

    if U == S:
        A -= 1
    elif U == T:
        B -= 1
    print('{} {}'.format(A,B))


if __name__ == '__main__':
    q1()
s,t=input().split(" ")
a,b=map(int,input().split(" "))
u=input()
 
if s==u:
  print(a-1, b)
else:
  print(a, b-1)
S, T = input().split()
A, B = map(int, input().split())
U = input()

if (U == S):
    print(A - 1, B)
else:
    print(A, B - 1)
s,t = input().split()
a,b = map(int,input().split())
u = input()
print(a-1, b) if u == s else print(a, b-1)
S, T = input().split()
A, B = map(int, input().split())
U = input()

if S == U:
    A -= 1
else:
    B -= 1

print(str(A) + ' ' + str(B))
def get_ints():
    return map(int, input().split())

s, t = input().split()
a, b = get_ints()
u = input()
if u == s:
    print(str(a - 1) + ' ' + str(b))
else:
    print(str(a) + ' ' + str(b - 1))
moji_arr = input()

first = moji_arr.split()[0]
second = moji_arr.split()[1]

num = input()
num_arr = list(map(int, num.split()))

u = input()

if u==first:
    num_arr[0] = num_arr[0] - 1
elif u==second:
    num_arr[1] = num_arr[1] - 1

print(num_arr[0], num_arr[1])
st = input().split(" ")
ab = input().split(" ")
ab[0] = int(ab[0])
ab[1] = int(ab[1])
u = input()

if st[0] == u:
    ab[0] -= 1
else:
    ab[1] -= 1

print(str(ab[0]) + " " + str(ab[1]))
s,t = input().split()
a,b = map(int, input().split())
u = input()

if s==u:
    print(a-1, b)
else:
    print(a, b-1)
S,T=map(str,input().split())
s,t=map(int,input().split())
U=input()

if S==U:
    print(s-1,t)
elif T==U:
    print(s,t-1)
val = input().split(' ')
s = val[0]
t = val[1]

val = input().split(' ')
a = int(val[0])
b = int(val[1])

u = input()

if s == u:
    a -= 1
elif t == u:
    b -= 1

print("{} {}".format(a, b))
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)
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)
def main(S,T,A,B,U):
    if S == U:
        print(A-1,B)
    if T == U:
        print(A,B-1)
    
S,T = input().split()
A,B = map(int, input().split())
U = input()
main(S,T,A,B,U)
s,t = map(str,input().split())
a,b = map(int,input().split())
u = input()

if s == u:
    print(a-1 , b)
else:
    print(a , b-1)
S,T=input().split()
A,B=map(int,input().split())
U=input()
if U==S:
  A-=1
elif U==T:
  B-=1
print(A,B)
def solve(s, t, a, b, u):
    t = s == u
    return "%d %d" % (a - t, b - 1 + t)

s, t = input().split()
a, b = map(int, input().split())
u = input()
print(solve(s, t, a, b, u))
s=list(input().split())
a,b=map(int,input().split())
print(a,b-1) if s.index(input())==1 else print(a-1,b)
S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:    A -= 1
else: B -= 1
print(A, B)
col = input().split()
num = list(map(int, input().split()))
col2 = input()

if col[0] == col2:
  print(num[0] - 1, num[1])
elif col[1] == col2:
  print(num[0], num[1] - 1)
a,b = input().split()
A,B = input().split()
c = input()
a = str(a)
b = str(b)
A = int(A)
B = int(B)
c = str(c)
d = A - 1
D = B - 1
if c == a:
    print(d,B)
elif c == b:
    print(A,D)
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
  A -= 1
else:
  B -= 1
print(A, B)
def main():
    s, t = [x for x in input().split()]
    a, b = [int(x) for x in input().split()]
    u = input()
    print(a-(s==u), b-(t==u))


if __name__ == '__main__':
    main()
s=input().split()
b = {}
a = list(map(int, input().split()))

for i in range(2):
  b[s[i]] = a[i]
  
b[input()] -=1

print(str(b[s[0]])+" "+str(b[s[1]]))
S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:
  A = A-1
else:
  B = B-1

print(' '.join(map(str, [A, B])))
S, T = input().split()
A, B = map(int,input().split())
U = input()

if S == U :
  a = A - 1
  b = B
else :
  a = A
  b = B - 1

print(a, b)
S,T = input().split()
A,B =map(int,input().split())
U = input()
if U==S:
    print(A-1,B)
else:
    print(A,B-1)
import sys

def main():
    k = input().replace('\n','').split()
    a = input().replace('\n','').split()
    u = input().replace('\n','')
    a[k.index(u)]=int(a[k.index(u)]) - 1
    print(str(a[0]) + ' ' + str(a[1]))
if __name__ == '__main__':
    input = sys.stdin.readline
    main()
s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()
if u == s:
    print(a-1, b)
if u == t:
    print(a, b-1)
s1, s2 = map(str, input().split())
a, b = map(int, input().split())
s3 = input()

if(s1==s3):print(a-1, b)
else:print(a, b-1)
import sys

INF = 1001001001

def resolve():
  s, t = input().split()
  a , b = map(int, input().split())
  u = input()
  if (s == u):
    print(a - 1, b)
  else:
    print(a, b - 1)
  return

if __name__ == "__main__":
    resolve()
s,t = input().split()
a,b = map(int,input().split())
u = input()

if u == s:
    a -= 1
else:
    b -= 1
    
print(a,b)
s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()

if u == s:
  a = a-1
else:
  b = b-1
print(a, b)
S, T = map(str,input().split())
A, B = map(int,input().split())
U = str(input())

if(S == U):
    A -= 1
elif(T == U):
    B -= 1
else:
    A
    B
    
print("{} {}".format(A, B))
s,t = input().split()
a,b = map(int,input().split())
u = input()

if u==s:
    print(a-1, b)
else:
    print(a,b-1)
s,t=input().split()
a,b=map(int, input().split())
u=input()

if u==s:
    print(a-1,b)
    
else:
    print(a,b-1)
s,t=map(str,input().split())
a,b=map(int,input().split())
u=input()
if s==u:
    print(str(a-1)+" "+str(b))
else:
    print(str(a)+" "+str(b-1))
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    S, T = read_str_list()
    A, B = read_int_list()
    U = read_str()
    if U == S:
      res = A - 1, B
    elif U == T:
      res = A, B - 1
    print(res[0], res[1])


main()
S, T = input().split()
A, B = map(int, input().split())
print(*(A-1,B) if S==input() else (A,B-1))
s, t = input().split()
a, b = map(int, input().split())
u = input()

if u == s:
    print(a-1, b)
else:
    print(a, b-1)
#入力
S, T = map(str, input().split())
A, B = map(int, input().split())
U = str(input())

#出力
if S == U:
    print( A-1,B )
else:
    print( A, B-1 )
st = [s for s in input().split()]
ab = [int(s) for s in input().split()]
u = input()

if u == st[0]:
  print(int(ab[0]-1),int(ab[1]))
else:
  print(int(ab[0]),int(ab[1]-1))
# coding: utf-8
# Your code here!
 
S,T = [i for i in input().split()]
A,B = [int(i) for i in input().split()]
U = input()

if S == U:
    A-=1
else:
    B-=1
print(A,B)
s,t=input().split()
a,b=map(int,input().split())
u=input()
if u==s:
  a-=1
else:
  b-=1
print(a,b)
a,b=map(str,input().split())
c,d=map(int,input().split())
e=input()
if a==e:
    c=c-1
else:
    d=d-1
print(c,d)
S,T = input().split()
A,B = map(int, input().split())
U = input()
 
if S == U:
  A -= 1
else:
  B -= 1
  
print(A,B)
ST = input().split()
S = ST[0]
T = ST[1]

AB = input().split()
A = int(AB[0])
B = int(AB[1])

U = input()

if S == U:
  print(A-1,B)
else:
  print(A,B-1)
s, t = input().split()
a, b = map(int, input().split())
u = input()
if s == u:
  a -= 1
elif t == u:
  b -= 1
print(a,b)
s,t = map(str, input().split())
a,b = map(int, input().split())
u = input()

if s == u:
  a -= 1
else:
  b -= 1

print(a,b)
S,T=input().split()
A,B=map(int,input().split())
U=input()
if U == S:
    print(A-1,B)
elif U == T:
    print(A,B-1)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s, t = input().split()
a, b = map(int, input().split())
u = input()
if s == u:
    print(a - 1, b)
else:
    print(a, b - 1)
S,T = input().split()
A,B = map(int,input().split())
U = input()
if S ==U:
  print(A-1,B)
else:
  print(A,B-1)
inputf = input

a,b = inputf().split(' ')
a_, b_ = inputf().split(' ')
a_ = int(a_)
b_ = int(b_)
c = inputf()

if c==a:
    a_ -= 1
else:
    b_ -= 1
    
print(a_, b_)