import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String s, t;
		int a, b;
		String u;
		Scanner scan = new Scanner(System.in);
		s = scan.next();
		t = scan.next();
		a = scan.nextInt();
		b = scan.nextInt();
		u = scan.next();

		if(s.equals(u)) {
			System.out.println((a-1) + " " + b);
		} else if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		}
		scan.close();
	}

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

	public static void main(String[] args) {
		String s, t;
		int a, b;
		String u;
		Scanner scan = new Scanner(System.in);
		s = scan.next();
		t = scan.next();
		a = scan.nextInt();
		b = scan.nextInt();
		u = scan.next();

		if(s.equals(u)) {
			System.out.println((a-1) + " " + b);
		} else if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		}
		scan.close();
	}

} Main public static void main(String[] args) {
		String s, t;
		int a, b;
		String u;
		Scanner scan = new Scanner(System.in);
		s = scan.next();
		t = scan.next();
		a = scan.nextInt();
		b = scan.nextInt();
		u = scan.next();

		if(s.equals(u)) {
			System.out.println((a-1) + " " + b);
		} else if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		}
		scan.close();
	} main {
		String s, t;
		int a, b;
		String u;
		Scanner scan = new Scanner(System.in);
		s = scan.next();
		t = scan.next();
		a = scan.nextInt();
		b = scan.nextInt();
		u = scan.next();

		if(s.equals(u)) {
			System.out.println((a-1) + " " + b);
		} else if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		}
		scan.close();
	} String s s t; t int a a b; b String u; u Scanner scan = new Scanner(System.in); scan new Scanner(System.in) s = scan.next() s scan.next() scan.next scan t = scan.next() t scan.next() scan.next scan a = scan.nextInt() a scan.nextInt() scan.nextInt scan b = scan.nextInt() b scan.nextInt() scan.nextInt scan u = scan.next() u scan.next() scan.next scan if(s.equals(u)) {
			System.out.println((a-1) + " " + b);
		} else if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		} s.equals(u) s.equals s u {
			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 if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		} t.equals(u) t.equals t u {
			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 scan.close() scan.close scan String[] args args public class Main {

	public static void main(String[] args) {
		String s, t;
		int a, b;
		String u;
		Scanner scan = new Scanner(System.in);
		s = scan.next();
		t = scan.next();
		a = scan.nextInt();
		b = scan.nextInt();
		u = scan.next();

		if(s.equals(u)) {
			System.out.println((a-1) + " " + b);
		} else if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		}
		scan.close();
	}

} public class Main {

	public static void main(String[] args) {
		String s, t;
		int a, b;
		String u;
		Scanner scan = new Scanner(System.in);
		s = scan.next();
		t = scan.next();
		a = scan.nextInt();
		b = scan.nextInt();
		u = scan.next();

		if(s.equals(u)) {
			System.out.println((a-1) + " " + b);
		} else if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		}
		scan.close();
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String s, t;
		int a, b;
		String u;
		Scanner scan = new Scanner(System.in);
		s = scan.next();
		t = scan.next();
		a = scan.nextInt();
		b = scan.nextInt();
		u = scan.next();

		if(s.equals(u)) {
			System.out.println((a-1) + " " + b);
		} else if(t.equals(u)){
			System.out.println(a + " " + (b-1));
		}
		scan.close();
	}

}
