S, T = map(str,input().split())
A, B = map(int,input().split())
U = str(input())

if S == U:
    A -= 1
    l = [A,B]
    print(' '.join(map(str,l)))
elif T == U:
    B -= 1
    l = [A, B]
    print(' '.join(map(str, l))) 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 = str(input()) U str(input()) str input() input if S == U:
    A -= 1
    l = [A,B]
    print(' '.join(map(str,l)))
elif T == U:
    B -= 1
    l = [A, B]
    print(' '.join(map(str, l))) S == U S U A -= 1 A 1 l = [A,B] l [A,B] A B print(' '.join(map(str,l))) print ' '.join(map(str,l)) ' '.join ' ' join map(str,l) map str l elif T == U:
    B -= 1
    l = [A, B]
    print(' '.join(map(str, l))) T == U T U B -= 1 B 1 l = [A, B] l [A, B] A B print(' '.join(map(str, l))) print ' '.join(map(str, l)) ' '.join ' ' join map(str, l) map str l l = [A,B] [A,B] l S, T = map(str,input().split()) map(str,input().split()) S T = map(str,input().split()) map(str,input().split()) T A, B = map(int,input().split()) map(int,input().split()) A B -= 1 1 B U = str(input()) str(input()) U l = [A, B] [A, B] l B = map(int,input().split()) map(int,input().split()) B A -= 1 1 A
S, T = map(str,input().split())
A, B = map(int,input().split())
U = str(input())

if S == U:
    A -= 1
    l = [A,B]
    print(' '.join(map(str,l)))
elif T == U:
    B -= 1
    l = [A, B]
    print(' '.join(map(str, l)))