import sys
import collections
input = sys.stdin.readline

s, t = map(str,input().split())
a, b = map(int, input().split())
u = input().strip()
if u == s:
	print(a - 1, b)
else:
	print(a, b - 1) import sys sys import collections collections input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline s, t = map(str,input().split()) s map(str,input().split()) map str input().split() ().split () input split t a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b u = input().strip() u input().strip() ().strip () input strip if u == s:
	print(a - 1, b)
else:
	print(a, b - 1) u == s u s print(a - 1, b) print a - 1 a 1 b print(a, b - 1) print a b - 1 b 1 u = input().strip() input().strip() u t = map(str,input().split()) map(str,input().split()) t b = map(int, input().split()) map(int, input().split()) b a, b = map(int, input().split()) map(int, input().split()) a s, t = map(str,input().split()) map(str,input().split()) s input = sys.stdin.readline sys.stdin.readline input
import sys
import collections
input = sys.stdin.readline

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