from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()[:-1]
    if U == S:
        A -= 1
    else:
        B -= 1
    
    print(A, B)


if __name__ == '__main__':
    main() from functools import reduce from fractions import gcd import math math import bisect bisect import itertools itertools import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline INF = float("inf") INF float("inf") float "inf" def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()[:-1]
    if U == S:
        A -= 1
    else:
        B -= 1
    
    print(A, B) main S, T = input().split() S 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()[:-1] U input()[:-1] () input :-1 -1 if U == S:
        A -= 1
    else:
        B -= 1
    
     U == S U S A -= 1 A 1 B -= 1 B 1 print(A, B) print A B if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main input = sys.stdin.readline sys.stdin.readline input INF = float("inf") float("inf") INF def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()[:-1]
    if U == S:
        A -= 1
    else:
        B -= 1
    
    print(A, B) def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()[:-1]
    if U == S:
        A -= 1
    else:
        B -= 1
    
    print(A, B) main
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()[:-1]
    if U == S:
        A -= 1
    else:
        B -= 1
    
    print(A, B)


if __name__ == '__main__':
    main()