import itertools

import math

import fractions

import functools

s, t = input().split()

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

u = eval(input())



if u == s:

    print((a-1,b))

else:

    print((a,b-1))
s, t = input().split()

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

u = eval(input())



if u == s:

    print((a-1,b))

else: print((a,b-1))
import itertools
import math
import fractions
import functools

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

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

-import itertools -import math -import fractions -import functools -