import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String red = sc.next();
		String bule = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = sc.next();
		
		if (ans.equals(red)){
			--A;
		}else{
			--B;
		}
		System.out.println(A + " " + B);
	
	}
}	 import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String red = sc.next();
		String bule = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = sc.next();
		
		if (ans.equals(red)){
			--A;
		}else{
			--B;
		}
		System.out.println(A + " " + B);
	
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String red = sc.next();
		String bule = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = sc.next();
		
		if (ans.equals(red)){
			--A;
		}else{
			--B;
		}
		System.out.println(A + " " + B);
	
	} main {
		Scanner sc = new Scanner(System.in);
		String red = sc.next();
		String bule = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = sc.next();
		
		if (ans.equals(red)){
			--A;
		}else{
			--B;
		}
		System.out.println(A + " " + B);
	
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String red = sc.next(); red sc.next() sc.next sc String bule = sc.next(); bule 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 ans = sc.next(); ans sc.next() sc.next sc if (ans.equals(red)){
			--A;
		}else{
			--B;
		} ans.equals(red) ans.equals ans red {
			--A;
		} --A A {
			--B;
		} --B B System.out.println(A + " " + B) System.out.println System.out System System.out A + " " + B A + " " + B A " " B String[] args args
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String red = sc.next();
		String bule = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = sc.next();
		
		if (ans.equals(red)){
			--A;
		}else{
			--B;
		}
		System.out.println(A + " " + B);
	
	}
}	