import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        int k1 = sc.nextInt();
        int k2 = sc.nextInt();
        String s = sc.next();
        if(s.equals(s1)){
            System.out.println((k1-1) + " " + k2);
        }else{
            System.out.println(k1 + " " + (k2-1));
        }
    }
} import java.util.*; util.* java import java.io.*; io.* java import java.math.*; math.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        int k1 = sc.nextInt();
        int k2 = sc.nextInt();
        String s = sc.next();
        if(s.equals(s1)){
            System.out.println((k1-1) + " " + k2);
        }else{
            System.out.println(k1 + " " + (k2-1));
        }
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        int k1 = sc.nextInt();
        int k2 = sc.nextInt();
        String s = sc.next();
        if(s.equals(s1)){
            System.out.println((k1-1) + " " + k2);
        }else{
            System.out.println(k1 + " " + (k2-1));
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        int k1 = sc.nextInt();
        int k2 = sc.nextInt();
        String s = sc.next();
        if(s.equals(s1)){
            System.out.println((k1-1) + " " + k2);
        }else{
            System.out.println(k1 + " " + (k2-1));
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s1 = sc.next(); s1 sc.next() sc.next sc String s2 = sc.next(); s2 sc.next() sc.next sc int k1 = sc.nextInt(); k1 sc.nextInt() sc.nextInt sc int k2 = sc.nextInt(); k2 sc.nextInt() sc.nextInt sc String s = sc.next(); s sc.next() sc.next sc if(s.equals(s1)){
            System.out.println((k1-1) + " " + k2);
        }else{
            System.out.println(k1 + " " + (k2-1));
        } s.equals(s1) s.equals s s1 {
            System.out.println((k1-1) + " " + k2);
        } System.out.println((k1-1) + " " + k2) System.out.println System.out System System.out (k1-1) + " " + k2 (k1-1) + " " + k2 (k1-1) k1 1 " " k2 {
            System.out.println(k1 + " " + (k2-1));
        } System.out.println(k1 + " " + (k2-1)) System.out.println System.out System System.out k1 + " " + (k2-1) k1 + " " + (k2-1) k1 " " (k2-1) k2 1 String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        int k1 = sc.nextInt();
        int k2 = sc.nextInt();
        String s = sc.next();
        if(s.equals(s1)){
            System.out.println((k1-1) + " " + k2);
        }else{
            System.out.println(k1 + " " + (k2-1));
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        int k1 = sc.nextInt();
        int k2 = sc.nextInt();
        String s = sc.next();
        if(s.equals(s1)){
            System.out.println((k1-1) + " " + k2);
        }else{
            System.out.println(k1 + " " + (k2-1));
        }
    }
} Main
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        int k1 = sc.nextInt();
        int k2 = sc.nextInt();
        String s = sc.next();
        if(s.equals(s1)){
            System.out.println((k1-1) + " " + k2);
        }else{
            System.out.println(k1 + " " + (k2-1));
        }
    }
}