import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String s = inp.next();
        String t = inp.next();
        int a = inp.nextInt();
        int b = inp.nextInt();
        String u = inp.next();
        if (s.equals(u)) {
            System.out.printf("%d %d", a - 1, b);
        }
        else {
            System.out.printf("%d %d", a, b - 1);
        }
        System.out.println();
    }
} import java.util.*; util.* java class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String s = inp.next();
        String t = inp.next();
        int a = inp.nextInt();
        int b = inp.nextInt();
        String u = inp.next();
        if (s.equals(u)) {
            System.out.printf("%d %d", a - 1, b);
        }
        else {
            System.out.printf("%d %d", a, b - 1);
        }
        System.out.println();
    }
} Main public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String s = inp.next();
        String t = inp.next();
        int a = inp.nextInt();
        int b = inp.nextInt();
        String u = inp.next();
        if (s.equals(u)) {
            System.out.printf("%d %d", a - 1, b);
        }
        else {
            System.out.printf("%d %d", a, b - 1);
        }
        System.out.println();
    } main {
        Scanner inp = new Scanner(System.in);
        String s = inp.next();
        String t = inp.next();
        int a = inp.nextInt();
        int b = inp.nextInt();
        String u = inp.next();
        if (s.equals(u)) {
            System.out.printf("%d %d", a - 1, b);
        }
        else {
            System.out.printf("%d %d", a, b - 1);
        }
        System.out.println();
    } Scanner inp = new Scanner(System.in); inp new Scanner(System.in) String s = inp.next(); s inp.next() inp.next inp String t = inp.next(); t inp.next() inp.next inp int a = inp.nextInt(); a inp.nextInt() inp.nextInt inp int b = inp.nextInt(); b inp.nextInt() inp.nextInt inp String u = inp.next(); u inp.next() inp.next inp if (s.equals(u)) {
            System.out.printf("%d %d", a - 1, b);
        }
        else {
            System.out.printf("%d %d", a, b - 1);
        } s.equals(u) s.equals s u {
            System.out.printf("%d %d", a - 1, b);
        } System.out.printf("%d %d", a - 1, b) System.out.printf System.out System System.out "%d %d" a - 1 a 1 b {
            System.out.printf("%d %d", a, b - 1);
        } System.out.printf("%d %d", a, b - 1) System.out.printf System.out System System.out "%d %d" a b - 1 b 1 System.out.println() System.out.println System.out System System.out String args[] args
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String s = inp.next();
        String t = inp.next();
        int a = inp.nextInt();
        int b = inp.nextInt();
        String u = inp.next();
        if (s.equals(u)) {
            System.out.printf("%d %d", a - 1, b);
        }
        else {
            System.out.printf("%d %d", a, b - 1);
        }
        System.out.println();
    }
}