import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String[] color = new String[2];
        int[] num = new int[2];
        Scanner scanner = new Scanner(System.in);
        color[0] = scanner.next();
        color[1] = scanner.next();
        num[0] = Integer.parseInt(scanner.next());
        num[1] = Integer.parseInt(scanner.next());
        if (scanner.next().equals(color[0])) {
            num[0] = num[0]-1;
        }else {
            num[1] = num[1]-1;
        }
        System.out.println(num[0]+" "+num[1]);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        String[] color = new String[2];
        int[] num = new int[2];
        Scanner scanner = new Scanner(System.in);
        color[0] = scanner.next();
        color[1] = scanner.next();
        num[0] = Integer.parseInt(scanner.next());
        num[1] = Integer.parseInt(scanner.next());
        if (scanner.next().equals(color[0])) {
            num[0] = num[0]-1;
        }else {
            num[1] = num[1]-1;
        }
        System.out.println(num[0]+" "+num[1]);
    }
} Main public static void main(String[] args) {
        String[] color = new String[2];
        int[] num = new int[2];
        Scanner scanner = new Scanner(System.in);
        color[0] = scanner.next();
        color[1] = scanner.next();
        num[0] = Integer.parseInt(scanner.next());
        num[1] = Integer.parseInt(scanner.next());
        if (scanner.next().equals(color[0])) {
            num[0] = num[0]-1;
        }else {
            num[1] = num[1]-1;
        }
        System.out.println(num[0]+" "+num[1]);
    } main {
        String[] color = new String[2];
        int[] num = new int[2];
        Scanner scanner = new Scanner(System.in);
        color[0] = scanner.next();
        color[1] = scanner.next();
        num[0] = Integer.parseInt(scanner.next());
        num[1] = Integer.parseInt(scanner.next());
        if (scanner.next().equals(color[0])) {
            num[0] = num[0]-1;
        }else {
            num[1] = num[1]-1;
        }
        System.out.println(num[0]+" "+num[1]);
    } String[] color = new String[2]; color new String[2] 2 int[] num = new int[2]; num new int[2] 2 Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) color[0] = scanner.next() color[0] color 0 scanner.next() scanner.next scanner color[1] = scanner.next() color[1] color 1 scanner.next() scanner.next scanner num[0] = Integer.parseInt(scanner.next()) num[0] num 0 Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner num[1] = Integer.parseInt(scanner.next()) num[1] num 1 Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner if (scanner.next().equals(color[0])) {
            num[0] = num[0]-1;
        }else {
            num[1] = num[1]-1;
        } scanner.next().equals(color[0]) scanner.next().equals scanner.next() scanner.next scanner color[0] color 0 {
            num[0] = num[0]-1;
        } num[0] = num[0]-1 num[0] num 0 num[0]-1 num[0] num 0 1 {
            num[1] = num[1]-1;
        } num[1] = num[1]-1 num[1] num 1 num[1]-1 num[1] num 1 1 System.out.println(num[0]+" "+num[1]) System.out.println System.out System System.out num[0]+" "+num[1] num[0]+" "+num[1] num[0] num 0 " " num[1] num 1 String[] args args public class Main {
    public static void main(String[] args) {
        String[] color = new String[2];
        int[] num = new int[2];
        Scanner scanner = new Scanner(System.in);
        color[0] = scanner.next();
        color[1] = scanner.next();
        num[0] = Integer.parseInt(scanner.next());
        num[1] = Integer.parseInt(scanner.next());
        if (scanner.next().equals(color[0])) {
            num[0] = num[0]-1;
        }else {
            num[1] = num[1]-1;
        }
        System.out.println(num[0]+" "+num[1]);
    }
} public class Main {
    public static void main(String[] args) {
        String[] color = new String[2];
        int[] num = new int[2];
        Scanner scanner = new Scanner(System.in);
        color[0] = scanner.next();
        color[1] = scanner.next();
        num[0] = Integer.parseInt(scanner.next());
        num[1] = Integer.parseInt(scanner.next());
        if (scanner.next().equals(color[0])) {
            num[0] = num[0]-1;
        }else {
            num[1] = num[1]-1;
        }
        System.out.println(num[0]+" "+num[1]);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String[] color = new String[2];
        int[] num = new int[2];
        Scanner scanner = new Scanner(System.in);
        color[0] = scanner.next();
        color[1] = scanner.next();
        num[0] = Integer.parseInt(scanner.next());
        num[1] = Integer.parseInt(scanner.next());
        if (scanner.next().equals(color[0])) {
            num[0] = num[0]-1;
        }else {
            num[1] = num[1]-1;
        }
        System.out.println(num[0]+" "+num[1]);
    }
}