import java.util.*;

public class Main {
        public static void main(String args[]) {
            Scanner sc = new Scanner(System.in);
            String a = sc.next();
            String b = sc.next();
            int x = sc.nextInt();
            int y = sc.nextInt();
            String o = sc.next();

            if (o.equals(a)) {
                x--;
                System.out.println(x + " " + y);
            }
            else if (o.equals(b)) {
                y--;
                System.out.println(x + " " + y);
            }
        }
} import java.util.*; util.* java public class Main {
        public static void main(String args[]) {
            Scanner sc = new Scanner(System.in);
            String a = sc.next();
            String b = sc.next();
            int x = sc.nextInt();
            int y = sc.nextInt();
            String o = sc.next();

            if (o.equals(a)) {
                x--;
                System.out.println(x + " " + y);
            }
            else if (o.equals(b)) {
                y--;
                System.out.println(x + " " + y);
            }
        }
} Main public static void main(String args[]) {
            Scanner sc = new Scanner(System.in);
            String a = sc.next();
            String b = sc.next();
            int x = sc.nextInt();
            int y = sc.nextInt();
            String o = sc.next();

            if (o.equals(a)) {
                x--;
                System.out.println(x + " " + y);
            }
            else if (o.equals(b)) {
                y--;
                System.out.println(x + " " + y);
            }
        } main {
            Scanner sc = new Scanner(System.in);
            String a = sc.next();
            String b = sc.next();
            int x = sc.nextInt();
            int y = sc.nextInt();
            String o = sc.next();

            if (o.equals(a)) {
                x--;
                System.out.println(x + " " + y);
            }
            else if (o.equals(b)) {
                y--;
                System.out.println(x + " " + y);
            }
        } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.next(); a sc.next() sc.next sc String b = sc.next(); b sc.next() sc.next sc int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc String o = sc.next(); o sc.next() sc.next sc if (o.equals(a)) {
                x--;
                System.out.println(x + " " + y);
            }
            else if (o.equals(b)) {
                y--;
                System.out.println(x + " " + y);
            } o.equals(a) o.equals o a {
                x--;
                System.out.println(x + " " + y);
            } x-- x System.out.println(x + " " + y) System.out.println System.out System System.out x + " " + y x + " " + y x " " y if (o.equals(b)) {
                y--;
                System.out.println(x + " " + y);
            } o.equals(b) o.equals o b {
                y--;
                System.out.println(x + " " + y);
            } y-- y System.out.println(x + " " + y) System.out.println System.out System System.out x + " " + y x + " " + y x " " y String args[] args public class Main {
        public static void main(String args[]) {
            Scanner sc = new Scanner(System.in);
            String a = sc.next();
            String b = sc.next();
            int x = sc.nextInt();
            int y = sc.nextInt();
            String o = sc.next();

            if (o.equals(a)) {
                x--;
                System.out.println(x + " " + y);
            }
            else if (o.equals(b)) {
                y--;
                System.out.println(x + " " + y);
            }
        }
} public class Main {
        public static void main(String args[]) {
            Scanner sc = new Scanner(System.in);
            String a = sc.next();
            String b = sc.next();
            int x = sc.nextInt();
            int y = sc.nextInt();
            String o = sc.next();

            if (o.equals(a)) {
                x--;
                System.out.println(x + " " + y);
            }
            else if (o.equals(b)) {
                y--;
                System.out.println(x + " " + y);
            }
        }
} Main
import java.util.*;

public class Main {
        public static void main(String args[]) {
            Scanner sc = new Scanner(System.in);
            String a = sc.next();
            String b = sc.next();
            int x = sc.nextInt();
            int y = sc.nextInt();
            String o = sc.next();

            if (o.equals(a)) {
                x--;
                System.out.println(x + " " + y);
            }
            else if (o.equals(b)) {
                y--;
                System.out.println(x + " " + y);
            }
        }
}
