import sys
import math
from collections import deque
from collections import defaultdict

def main():
    s, t = input().split()
    a, b = list(map(int,sys.stdin.readline().split()))
    u = input()
    if u == s:
        a -= 1
    else: b -= 1
    print(a,b)
    return 0

if __name__ == "__main__":
    main() import sys sys import math math from collections import deque from collections import defaultdict def main():
    s, t = input().split()
    a, b = list(map(int,sys.stdin.readline().split()))
    u = input()
    if u == s:
        a -= 1
    else: b -= 1
    print(a,b)
    return 0 main s, t = input().split() s input().split() ().split () input split t a, b = list(map(int,sys.stdin.readline().split())) a list(map(int,sys.stdin.readline().split())) list map(int,sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split b u = input() u input() input if u == s:
        a -= 1
    else: b -= 1
     u == s u s a -= 1 a 1 print(a,b) print a b return 0 0 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    s, t = input().split()
    a, b = list(map(int,sys.stdin.readline().split()))
    u = input()
    if u == s:
        a -= 1
    else: b -= 1
    print(a,b)
    return 0 def main():
    s, t = input().split()
    a, b = list(map(int,sys.stdin.readline().split()))
    u = input()
    if u == s:
        a -= 1
    else: b -= 1
    print(a,b)
    return 0 main
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    s, t = input().split()
    a, b = list(map(int,sys.stdin.readline().split()))
    u = input()
    if u == s:
        a -= 1
    else: b -= 1
    print(a,b)
    return 0

if __name__ == "__main__":
    main()