import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] S = scn.next().toCharArray(), T = scn.next().toCharArray();
		int A = scn.nextInt(), B = scn.nextInt();
		scn.nextLine();
		char[] U = scn.next().toCharArray();
		boolean a = true;
		for(int i = 0;i < S.length;i++) {
			a &= S[i] == U[i];
		}
		System.out.println((a)?(A-1) + " " + B:A + " " + (B-1));
	}

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

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] S = scn.next().toCharArray(), T = scn.next().toCharArray();
		int A = scn.nextInt(), B = scn.nextInt();
		scn.nextLine();
		char[] U = scn.next().toCharArray();
		boolean a = true;
		for(int i = 0;i < S.length;i++) {
			a &= S[i] == U[i];
		}
		System.out.println((a)?(A-1) + " " + B:A + " " + (B-1));
	}

} Main public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] S = scn.next().toCharArray(), T = scn.next().toCharArray();
		int A = scn.nextInt(), B = scn.nextInt();
		scn.nextLine();
		char[] U = scn.next().toCharArray();
		boolean a = true;
		for(int i = 0;i < S.length;i++) {
			a &= S[i] == U[i];
		}
		System.out.println((a)?(A-1) + " " + B:A + " " + (B-1));
	} main {
		Scanner scn = new Scanner(System.in);
		char[] S = scn.next().toCharArray(), T = scn.next().toCharArray();
		int A = scn.nextInt(), B = scn.nextInt();
		scn.nextLine();
		char[] U = scn.next().toCharArray();
		boolean a = true;
		for(int i = 0;i < S.length;i++) {
			a &= S[i] == U[i];
		}
		System.out.println((a)?(A-1) + " " + B:A + " " + (B-1));
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) char[] S = scn.next().toCharArray() S scn.next().toCharArray() scn.next().toCharArray scn.next() scn.next scn T = scn.next().toCharArray(); T scn.next().toCharArray() scn.next().toCharArray scn.next() scn.next scn int A = scn.nextInt() A scn.nextInt() scn.nextInt scn B = scn.nextInt(); B scn.nextInt() scn.nextInt scn scn.nextLine() scn.nextLine scn char[] U = scn.next().toCharArray(); U scn.next().toCharArray() scn.next().toCharArray scn.next() scn.next scn boolean a = true; a true for(int i = 0;i < S.length;i++) {
			a &= S[i] == U[i];
		} int i = 0; int i = 0; i 0 i < S.length i S.length S S.length i++ i++ i {
			a &= S[i] == U[i];
		} {
			a &= S[i] == U[i];
		} a &= S[i] == U[i] a S[i] == U[i] S[i] S i U[i] U i System.out.println((a)?(A-1) + " " + B:A + " " + (B-1)) System.out.println System.out System System.out (a)?(A-1) + " " + B:A + " " + (B-1) (a) (A-1) + " " + B (A-1) + " " + B (A-1) A 1 " " B A + " " + (B-1) A + " " + (B-1) A " " (B-1) B 1 String[] args args public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] S = scn.next().toCharArray(), T = scn.next().toCharArray();
		int A = scn.nextInt(), B = scn.nextInt();
		scn.nextLine();
		char[] U = scn.next().toCharArray();
		boolean a = true;
		for(int i = 0;i < S.length;i++) {
			a &= S[i] == U[i];
		}
		System.out.println((a)?(A-1) + " " + B:A + " " + (B-1));
	}

} public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] S = scn.next().toCharArray(), T = scn.next().toCharArray();
		int A = scn.nextInt(), B = scn.nextInt();
		scn.nextLine();
		char[] U = scn.next().toCharArray();
		boolean a = true;
		for(int i = 0;i < S.length;i++) {
			a &= S[i] == U[i];
		}
		System.out.println((a)?(A-1) + " " + B:A + " " + (B-1));
	}

} Main
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] S = scn.next().toCharArray(), T = scn.next().toCharArray();
		int A = scn.nextInt(), B = scn.nextInt();
		scn.nextLine();
		char[] U = scn.next().toCharArray();
		boolean a = true;
		for(int i = 0;i < S.length;i++) {
			a &= S[i] == U[i];
		}
		System.out.println((a)?(A-1) + " " + B:A + " " + (B-1));
	}

}