S,T = input().split()
A,B = (int(x) for x in input().split())
U   = input()
if S==U:
    print('{} {}'.format(A-1,B))
else:
    print('{} {}'.format(A,B-1)) S,T = input().split() S input().split() ().split () input split T int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x A,B = (int(x) for x in input().split()) A (int(x) for x in input().split()) B U   = input() U input() input if S==U:
    print('{} {}'.format(A-1,B))
else:
    print('{} {}'.format(A,B-1)) S==U S U print('{} {}'.format(A-1,B)) print '{} {}'.format(A-1,B) '{} {}'.format '{} {}' format A-1 A 1 B print('{} {}'.format(A,B-1)) print '{} {}'.format(A,B-1) '{} {}'.format '{} {}' format A B-1 B 1 T = input().split() input().split() T A,B = (int(x) for x in input().split()) (int(x) for x in input().split()) A B = (int(x) for x in input().split()) (int(x) for x in input().split()) B U   = input() input() U S,T = input().split() input().split() S
S,T = input().split()
A,B = (int(x) for x in input().split())
U   = input()
if S==U:
    print('{} {}'.format(A-1,B))
else:
    print('{} {}'.format(A,B-1))