import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] colors = new String[2];
        int[] nums = new int[2];
        for (int i = 0; i < 2; i++) {
            colors[i] = sc.next();
        }
        for (int i = 0; i < 2; i++) {
            nums[i] = sc.nextInt();
        }
        String color = sc.next();
        for (int i = 0; i < 2; i++) {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        }
        System.out.println(nums[0] + " " + nums[1]);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] colors = new String[2];
        int[] nums = new int[2];
        for (int i = 0; i < 2; i++) {
            colors[i] = sc.next();
        }
        for (int i = 0; i < 2; i++) {
            nums[i] = sc.nextInt();
        }
        String color = sc.next();
        for (int i = 0; i < 2; i++) {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        }
        System.out.println(nums[0] + " " + nums[1]);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] colors = new String[2];
        int[] nums = new int[2];
        for (int i = 0; i < 2; i++) {
            colors[i] = sc.next();
        }
        for (int i = 0; i < 2; i++) {
            nums[i] = sc.nextInt();
        }
        String color = sc.next();
        for (int i = 0; i < 2; i++) {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        }
        System.out.println(nums[0] + " " + nums[1]);
    } main {
        Scanner sc = new Scanner(System.in);
        String[] colors = new String[2];
        int[] nums = new int[2];
        for (int i = 0; i < 2; i++) {
            colors[i] = sc.next();
        }
        for (int i = 0; i < 2; i++) {
            nums[i] = sc.nextInt();
        }
        String color = sc.next();
        for (int i = 0; i < 2; i++) {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        }
        System.out.println(nums[0] + " " + nums[1]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] colors = new String[2]; colors new String[2] 2 int[] nums = new int[2]; nums new int[2] 2 for (int i = 0; i < 2; i++) {
            colors[i] = sc.next();
        } int i = 0; int i = 0; i 0 i < 2 i 2 i++ i++ i {
            colors[i] = sc.next();
        } {
            colors[i] = sc.next();
        } colors[i] = sc.next() colors[i] colors i sc.next() sc.next sc for (int i = 0; i < 2; i++) {
            nums[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < 2 i 2 i++ i++ i {
            nums[i] = sc.nextInt();
        } {
            nums[i] = sc.nextInt();
        } nums[i] = sc.nextInt() nums[i] nums i sc.nextInt() sc.nextInt sc String color = sc.next(); color sc.next() sc.next sc for (int i = 0; i < 2; i++) {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        } int i = 0; int i = 0; i 0 i < 2 i 2 i++ i++ i {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        } {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        } if (colors[i].equals(color)) {
                nums[i]--;
                break;
            } colors[i].equals(color) colors[i].equals colors[i] colors i color {
                nums[i]--;
                break;
            } nums[i]-- nums[i] nums i break; System.out.println(nums[0] + " " + nums[1]) System.out.println System.out System System.out nums[0] + " " + nums[1] nums[0] + " " + nums[1] nums[0] nums 0 " " nums[1] nums 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] colors = new String[2];
        int[] nums = new int[2];
        for (int i = 0; i < 2; i++) {
            colors[i] = sc.next();
        }
        for (int i = 0; i < 2; i++) {
            nums[i] = sc.nextInt();
        }
        String color = sc.next();
        for (int i = 0; i < 2; i++) {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        }
        System.out.println(nums[0] + " " + nums[1]);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] colors = new String[2];
        int[] nums = new int[2];
        for (int i = 0; i < 2; i++) {
            colors[i] = sc.next();
        }
        for (int i = 0; i < 2; i++) {
            nums[i] = sc.nextInt();
        }
        String color = sc.next();
        for (int i = 0; i < 2; i++) {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        }
        System.out.println(nums[0] + " " + nums[1]);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] colors = new String[2];
        int[] nums = new int[2];
        for (int i = 0; i < 2; i++) {
            colors[i] = sc.next();
        }
        for (int i = 0; i < 2; i++) {
            nums[i] = sc.nextInt();
        }
        String color = sc.next();
        for (int i = 0; i < 2; i++) {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        }
        System.out.println(nums[0] + " " + nums[1]);
    }
}