s,t = input().split()
snum, tnum = map(int,input().split())
selection = input()

if (selection == s):
    print(snum-1,tnum)
else:
    print(snum,tnum-1) s,t = input().split() s input().split() ().split () input split t snum, tnum = map(int,input().split()) snum map(int,input().split()) map int input().split() ().split () input split tnum selection = input() selection input() input if (selection == s):
    print(snum-1,tnum)
else:
    print(snum,tnum-1) selection == s selection s print(snum-1,tnum) print snum-1 snum 1 tnum print(snum,tnum-1) print snum tnum-1 tnum 1 selection = input() input() selection tnum = map(int,input().split()) map(int,input().split()) tnum t = input().split() input().split() t s,t = input().split() input().split() s snum, tnum = map(int,input().split()) map(int,input().split()) snum
s,t = input().split()
snum, tnum = map(int,input().split())
selection = input()

if (selection == s):
    print(snum-1,tnum)
else:
    print(snum,tnum-1)