import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		String t=scan.nextLine();
		int a=scan.nextInt();
		int b=scan.nextInt();
		String h=scan.next();
		if(s.contains(h))
		{
			System.out.println((a-1)+" "+b);
		}
		else 
		{
			System.out.println(a+" "+(b-1));
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		String t=scan.nextLine();
		int a=scan.nextInt();
		int b=scan.nextInt();
		String h=scan.next();
		if(s.contains(h))
		{
			System.out.println((a-1)+" "+b);
		}
		else 
		{
			System.out.println(a+" "+(b-1));
		}
	}

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

} public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		String t=scan.nextLine();
		int a=scan.nextInt();
		int b=scan.nextInt();
		String h=scan.next();
		if(s.contains(h))
		{
			System.out.println((a-1)+" "+b);
		}
		else 
		{
			System.out.println(a+" "+(b-1));
		}
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		String t=scan.nextLine();
		int a=scan.nextInt();
		int b=scan.nextInt();
		String h=scan.next();
		if(s.contains(h))
		{
			System.out.println((a-1)+" "+b);
		}
		else 
		{
			System.out.println(a+" "+(b-1));
		}
	}

}
