import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String S=s.next(),T=s.next();
		int A=s.nextInt(),B=s.nextInt();
		String U=s.next();
		System.out.println(U.equals(S)?(A-1)+" "+B:A+" "+(B-1));
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String S=s.next(),T=s.next();
		int A=s.nextInt(),B=s.nextInt();
		String U=s.next();
		System.out.println(U.equals(S)?(A-1)+" "+B:A+" "+(B-1));
	}
} Main public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String S=s.next(),T=s.next();
		int A=s.nextInt(),B=s.nextInt();
		String U=s.next();
		System.out.println(U.equals(S)?(A-1)+" "+B:A+" "+(B-1));
	} main {
		Scanner s=new Scanner(System.in);
		String S=s.next(),T=s.next();
		int A=s.nextInt(),B=s.nextInt();
		String U=s.next();
		System.out.println(U.equals(S)?(A-1)+" "+B:A+" "+(B-1));
	} Scanner s=new Scanner(System.in); s new Scanner(System.in) String S=s.next() S s.next() s.next s T=s.next(); T s.next() s.next s int A=s.nextInt() A s.nextInt() s.nextInt s B=s.nextInt(); B s.nextInt() s.nextInt s String U=s.next(); U s.next() s.next s System.out.println(U.equals(S)?(A-1)+" "+B:A+" "+(B-1)) System.out.println System.out System System.out U.equals(S)?(A-1)+" "+B:A+" "+(B-1) U.equals(S) U.equals U S (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 s=new Scanner(System.in);
		String S=s.next(),T=s.next();
		int A=s.nextInt(),B=s.nextInt();
		String U=s.next();
		System.out.println(U.equals(S)?(A-1)+" "+B:A+" "+(B-1));
	}
} public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String S=s.next(),T=s.next();
		int A=s.nextInt(),B=s.nextInt();
		String U=s.next();
		System.out.println(U.equals(S)?(A-1)+" "+B:A+" "+(B-1));
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String S=s.next(),T=s.next();
		int A=s.nextInt(),B=s.nextInt();
		String U=s.next();
		System.out.println(U.equals(S)?(A-1)+" "+B:A+" "+(B-1));
	}
}