import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute7_4();
	}
	
	private static void execute7_4() {
		try (Scanner sc = new Scanner(System.in)) {
			String A = sc.next();
			String B = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String U = sc.next();
			
			if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			}
		}
	}
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.HashMap; HashMap java.util import java.util.HashSet; HashSet java.util import java.util.List; List java.util import java.util.Map; Map java.util import java.util.Queue; Queue java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {

	public static void main(String[] args) {
		execute7_4();
	}
	
	private static void execute7_4() {
		try (Scanner sc = new Scanner(System.in)) {
			String A = sc.next();
			String B = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String U = sc.next();
			
			if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			}
		}
	}
} Main public static void main(String[] args) {
		execute7_4();
	} main {
		execute7_4();
	} execute7_4() execute7_4 String[] args args private static void execute7_4() {
		try (Scanner sc = new Scanner(System.in)) {
			String A = sc.next();
			String B = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String U = sc.next();
			
			if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			}
		}
	} execute7_4 {
		try (Scanner sc = new Scanner(System.in)) {
			String A = sc.next();
			String B = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String U = sc.next();
			
			if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			}
		}
	} try (Scanner sc = new Scanner(System.in)) {
			String A = sc.next();
			String B = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String U = sc.next();
			
			if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			}
		} {
			String A = sc.next();
			String B = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String U = sc.next();
			
			if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			}
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) String A = sc.next(); A sc.next() sc.next sc String B = sc.next(); B sc.next() sc.next sc int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc String U = sc.next(); U sc.next() sc.next sc if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			} U.equals(A) U.equals U A {
				System.out.println((a-1)+" "+b);
			} System.out.println((a-1)+" "+b) System.out.println System.out System System.out (a-1)+" "+b (a-1)+" "+b (a-1) a 1 " " b {
				System.out.println(a+" "+(b-1));
			} System.out.println(a+" "+(b-1)) System.out.println System.out System System.out a+" "+(b-1) a+" "+(b-1) a " " (b-1) b 1 public class Main {

	public static void main(String[] args) {
		execute7_4();
	}
	
	private static void execute7_4() {
		try (Scanner sc = new Scanner(System.in)) {
			String A = sc.next();
			String B = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String U = sc.next();
			
			if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			}
		}
	}
} public class Main {

	public static void main(String[] args) {
		execute7_4();
	}
	
	private static void execute7_4() {
		try (Scanner sc = new Scanner(System.in)) {
			String A = sc.next();
			String B = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String U = sc.next();
			
			if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			}
		}
	}
} Main
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute7_4();
	}
	
	private static void execute7_4() {
		try (Scanner sc = new Scanner(System.in)) {
			String A = sc.next();
			String B = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			String U = sc.next();
			
			if(U.equals(A)) {
				System.out.println((a-1)+" "+b);
			}else {
				System.out.println(a+" "+(b-1));
			}
		}
	}
}