import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

//		System.out.println(S);

//		System.out.println(U.equals(S)?A-1:B-1);
		if (U.equals(S)) {
			System.out.println(A-1);
			System.out.println(B);
		} else if (U.equals(T)){
			System.out.println(A);
			System.out.println(B-1);
		}

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

//		System.out.println(S);

//		System.out.println(U.equals(S)?A-1:B-1);
		if (U.equals(S)) {
			System.out.println(A-1);
			System.out.println(B);
		} else if (U.equals(T)){
			System.out.println(A);
			System.out.println(B-1);
		}

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

//		System.out.println(S);

//		System.out.println(U.equals(S)?A-1:B-1);
		if (U.equals(S)) {
			System.out.println(A-1);
			System.out.println(B);
		} else if (U.equals(T)){
			System.out.println(A);
			System.out.println(B-1);
		}

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

//		System.out.println(S);

//		System.out.println(U.equals(S)?A-1:B-1);
		if (U.equals(S)) {
			System.out.println(A-1);
			System.out.println(B);
		} else if (U.equals(T)){
			System.out.println(A);
			System.out.println(B-1);
		}

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String S = scanner.next(); S scanner.next() scanner.next scanner String T = scanner.next(); T scanner.next() scanner.next scanner int A = scanner.nextInt(); A scanner.nextInt() scanner.nextInt scanner int B = scanner.nextInt(); B scanner.nextInt() scanner.nextInt scanner String U = scanner.next(); U scanner.next() scanner.next scanner if (U.equals(S)) {
			System.out.println(A-1);
			System.out.println(B);
		} else if (U.equals(T)){
			System.out.println(A);
			System.out.println(B-1);
		} U.equals(S) U.equals U S {
			System.out.println(A-1);
			System.out.println(B);
		} System.out.println(A-1) System.out.println System.out System System.out A-1 A 1 System.out.println(B) System.out.println System.out System System.out B if (U.equals(T)){
			System.out.println(A);
			System.out.println(B-1);
		} U.equals(T) U.equals U T {
			System.out.println(A);
			System.out.println(B-1);
		} System.out.println(A) System.out.println System.out System System.out A System.out.println(B-1) System.out.println System.out System System.out B-1 B 1 String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

//		System.out.println(S);

//		System.out.println(U.equals(S)?A-1:B-1);
		if (U.equals(S)) {
			System.out.println(A-1);
			System.out.println(B);
		} else if (U.equals(T)){
			System.out.println(A);
			System.out.println(B-1);
		}

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

//		System.out.println(S);

//		System.out.println(U.equals(S)?A-1:B-1);
		if (U.equals(S)) {
			System.out.println(A-1);
			System.out.println(B);
		} else if (U.equals(T)){
			System.out.println(A);
			System.out.println(B-1);
		}

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

//		System.out.println(S);

//		System.out.println(U.equals(S)?A-1:B-1);
		if (U.equals(S)) {
			System.out.println(A-1);
			System.out.println(B);
		} else if (U.equals(T)){
			System.out.println(A);
			System.out.println(B-1);
		}

	}

}