import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();

        int c = sc.nextInt();
        int d = sc.nextInt();

        String e = sc.next();

        if (e.equals(a))
            System.out.println((c - 1) + " " + d);
        else
            System.out.println(c + " " + (d - 1));
    }
} import java.util.*; util.* java import java.io.*; io.* java import java.lang.*; lang.* 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 c = sc.nextInt();
        int d = sc.nextInt();

        String e = sc.next();

        if (e.equals(a))
            System.out.println((c - 1) + " " + d);
        else
            System.out.println(c + " " + (d - 1));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();

        int c = sc.nextInt();
        int d = sc.nextInt();

        String e = sc.next();

        if (e.equals(a))
            System.out.println((c - 1) + " " + d);
        else
            System.out.println(c + " " + (d - 1));
    } main {
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();

        int c = sc.nextInt();
        int d = sc.nextInt();

        String e = sc.next();

        if (e.equals(a))
            System.out.println((c - 1) + " " + d);
        else
            System.out.println(c + " " + (d - 1));
    } 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 c = sc.nextInt(); c sc.nextInt() sc.nextInt sc int d = sc.nextInt(); d sc.nextInt() sc.nextInt sc String e = sc.next(); e sc.next() sc.next sc if (e.equals(a))
            System.out.println((c - 1) + " " + d);
        else
            System.out.println(c + " " + (d - 1)); e.equals(a) e.equals e a System.out.println((c - 1) + " " + d) System.out.println System.out System System.out (c - 1) + " " + d (c - 1) + " " + d (c - 1) c 1 " " d System.out.println(c + " " + (d - 1)) System.out.println System.out System System.out c + " " + (d - 1) c + " " + (d - 1) c " " (d - 1) d 1 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 c = sc.nextInt();
        int d = sc.nextInt();

        String e = sc.next();

        if (e.equals(a))
            System.out.println((c - 1) + " " + d);
        else
            System.out.println(c + " " + (d - 1));
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();

        int c = sc.nextInt();
        int d = sc.nextInt();

        String e = sc.next();

        if (e.equals(a))
            System.out.println((c - 1) + " " + d);
        else
            System.out.println(c + " " + (d - 1));
    }
} Main
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();

        int c = sc.nextInt();
        int d = sc.nextInt();

        String e = sc.next();

        if (e.equals(a))
            System.out.println((c - 1) + " " + d);
        else
            System.out.println(c + " " + (d - 1));
    }
}
