import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		}
	}

} Main public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		}
	} main {
		try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		}
	} try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		} {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		} 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 na = sc.nextInt(); na sc.nextInt() sc.nextInt sc int nb = sc.nextInt(); nb sc.nextInt() sc.nextInt sc String c = sc.next(); c sc.next() sc.next sc if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			} a.equals(c) a.equals a c {
				System.out.print(na - 1 + " " + nb);
			} System.out.print(na - 1 + " " + nb) System.out.print System.out System System.out na - 1 + " " + nb na - 1 + " " + nb na - 1 na 1 " " nb {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			} nb = nb - 1 nb nb - 1 nb 1 System.out.print(na + " " + nb) System.out.print System.out System System.out na + " " + nb na + " " + nb na " " nb String[] args args public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		}
	}

} public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		}
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			int na = sc.nextInt();
			int nb = sc.nextInt();
			String c = sc.next();
			if (a.equals(c)) {
				System.out.print(na - 1 + " " + nb);
			} else {
				nb = nb - 1;
				System.out.print(na + " " + nb);
			}
		}
	}

}
