import java.util.*;

import java.io.*;
 
public class Main{

    public static int stringToInt(char i, int[] a){
        if(i == 'A') return a[0];
        if(i == 'B') return a[1];
        if(i == 'C') return a[2];
        return 0;
    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        int A = s.nextInt();
        int B = s.nextInt();
        String U = s.next();
        
        if(U.equals(S)){
            A--;
        }else{
            B--;
        }
        
        
        System.out.println(A + " " + B);
        
        
	}
}  import java.util.*; util.* java import java.io.*; io.* java public class Main{

    public static int stringToInt(char i, int[] a){
        if(i == 'A') return a[0];
        if(i == 'B') return a[1];
        if(i == 'C') return a[2];
        return 0;
    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        int A = s.nextInt();
        int B = s.nextInt();
        String U = s.next();
        
        if(U.equals(S)){
            A--;
        }else{
            B--;
        }
        
        
        System.out.println(A + " " + B);
        
        
	}
} Main public static int stringToInt(char i, int[] a){
        if(i == 'A') return a[0];
        if(i == 'B') return a[1];
        if(i == 'C') return a[2];
        return 0;
    } stringToInt {
        if(i == 'A') return a[0];
        if(i == 'B') return a[1];
        if(i == 'C') return a[2];
        return 0;
    } if(i == 'A') return a[0]; i == 'A' i 'A' return a[0]; a[0] a 0 if(i == 'B') return a[1]; i == 'B' i 'B' return a[1]; a[1] a 1 if(i == 'C') return a[2]; i == 'C' i 'C' return a[2]; a[2] a 2 return 0; 0 char i i int[] a a public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        int A = s.nextInt();
        int B = s.nextInt();
        String U = s.next();
        
        if(U.equals(S)){
            A--;
        }else{
            B--;
        }
        
        
        System.out.println(A + " " + B);
        
        
	} main {
		Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        int A = s.nextInt();
        int B = s.nextInt();
        String U = s.next();
        
        if(U.equals(S)){
            A--;
        }else{
            B--;
        }
        
        
        System.out.println(A + " " + B);
        
        
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) String S = s.next(); S s.next() s.next s String T = s.next(); T s.next() s.next s int A = s.nextInt(); A s.nextInt() s.nextInt s int B = s.nextInt(); B s.nextInt() s.nextInt s String U = s.next(); U s.next() s.next s if(U.equals(S)){
            A--;
        }else{
            B--;
        } U.equals(S) U.equals U S {
            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[] $ $ public class Main{

    public static int stringToInt(char i, int[] a){
        if(i == 'A') return a[0];
        if(i == 'B') return a[1];
        if(i == 'C') return a[2];
        return 0;
    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        int A = s.nextInt();
        int B = s.nextInt();
        String U = s.next();
        
        if(U.equals(S)){
            A--;
        }else{
            B--;
        }
        
        
        System.out.println(A + " " + B);
        
        
	}
} public class Main{

    public static int stringToInt(char i, int[] a){
        if(i == 'A') return a[0];
        if(i == 'B') return a[1];
        if(i == 'C') return a[2];
        return 0;
    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        int A = s.nextInt();
        int B = s.nextInt();
        String U = s.next();
        
        if(U.equals(S)){
            A--;
        }else{
            B--;
        }
        
        
        System.out.println(A + " " + B);
        
        
	}
} Main
import java.util.*;

import java.io.*;
 
public class Main{

    public static int stringToInt(char i, int[] a){
        if(i == 'A') return a[0];
        if(i == 'B') return a[1];
        if(i == 'C') return a[2];
        return 0;
    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        int A = s.nextInt();
        int B = s.nextInt();
        String U = s.next();
        
        if(U.equals(S)){
            A--;
        }else{
            B--;
        }
        
        
        System.out.println(A + " " + B);
        
        
	}
} 