import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		String u = sc.next();
		sc.close();
		out.print(u.equals(s)?a-1:a);
		out.print(" ");
		out.println(u.equals(t)?b-1:b);
	}
} import java.util.*; util.* java import java.io.PrintWriter; PrintWriter java.io import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		String u = sc.next();
		sc.close();
		out.print(u.equals(s)?a-1:a);
		out.print(" ");
		out.println(u.equals(t)?b-1:b);
	}
} Main public static final int MOD = 1000000007; MOD 1000000007 public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		String u = sc.next();
		sc.close();
		out.print(u.equals(s)?a-1:a);
		out.print(" ");
		out.println(u.equals(t)?b-1:b);
	} main {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		String u = sc.next();
		sc.close();
		out.print(u.equals(s)?a-1:a);
		out.print(" ");
		out.println(u.equals(t)?b-1:b);
	} int i i j; j Scanner sc = new Scanner(in); sc new Scanner(in) String s = sc.next(); s sc.next() sc.next sc String t = sc.next(); t sc.next() sc.next sc int a = parseInt(sc.next()); a parseInt(sc.next()) parseInt sc.next() sc.next sc int b = parseInt(sc.next()); b parseInt(sc.next()) parseInt sc.next() sc.next sc String u = sc.next(); u sc.next() sc.next sc sc.close() sc.close sc out.print(u.equals(s)?a-1:a) out.print out u.equals(s)?a-1:a u.equals(s) u.equals u s a-1 a 1 a out.print(" ") out.print out " " out.println(u.equals(t)?b-1:b) out.println out u.equals(t)?b-1:b u.equals(t) u.equals u t b-1 b 1 b String[] args args public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		String u = sc.next();
		sc.close();
		out.print(u.equals(s)?a-1:a);
		out.print(" ");
		out.println(u.equals(t)?b-1:b);
	}
} public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		String u = sc.next();
		sc.close();
		out.print(u.equals(s)?a-1:a);
		out.print(" ");
		out.println(u.equals(t)?b-1:b);
	}
} Main
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		String u = sc.next();
		sc.close();
		out.print(u.equals(s)?a-1:a);
		out.print(" ");
		out.println(u.equals(t)?b-1:b);
	}
}
