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

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        String T = in.next();
        int A = in.nextInt();
        int B = in.nextInt();
        String U = in.next();

        if(S.equals(U))
        {
            System.out.println(A-1);
            System.out.println(B);
        }
        else if(T.equals(U))
        {
            System.out.println(A);
            System.out.println(B-1);
        }
        else
            {
                System.out.println("ERROR");
            }



    }


 }









 import java.util.*; util.* java import java.io.*; io.* java import static java.lang.Character.isUpperCase; import static java.lang.Character.isUpperCase; import static java.lang.Character.isUpperCase; public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        String T = in.next();
        int A = in.nextInt();
        int B = in.nextInt();
        String U = in.next();

        if(S.equals(U))
        {
            System.out.println(A-1);
            System.out.println(B);
        }
        else if(T.equals(U))
        {
            System.out.println(A);
            System.out.println(B-1);
        }
        else
            {
                System.out.println("ERROR");
            }



    }


 } Main public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        String T = in.next();
        int A = in.nextInt();
        int B = in.nextInt();
        String U = in.next();

        if(S.equals(U))
        {
            System.out.println(A-1);
            System.out.println(B);
        }
        else if(T.equals(U))
        {
            System.out.println(A);
            System.out.println(B-1);
        }
        else
            {
                System.out.println("ERROR");
            }



    } main {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        String T = in.next();
        int A = in.nextInt();
        int B = in.nextInt();
        String U = in.next();

        if(S.equals(U))
        {
            System.out.println(A-1);
            System.out.println(B);
        }
        else if(T.equals(U))
        {
            System.out.println(A);
            System.out.println(B-1);
        }
        else
            {
                System.out.println("ERROR");
            }



    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String S = in.next(); S in.next() in.next in String T = in.next(); T in.next() in.next in int A = in.nextInt(); A in.nextInt() in.nextInt in int B = in.nextInt(); B in.nextInt() in.nextInt in String U = in.next(); U in.next() in.next in if(S.equals(U))
        {
            System.out.println(A-1);
            System.out.println(B);
        }
        else if(T.equals(U))
        {
            System.out.println(A);
            System.out.println(B-1);
        }
        else
            {
                System.out.println("ERROR");
            } S.equals(U) S.equals S U {
            System.out.println(A-1);
            System.out.println(B);
        } System.out.println(A-1) System.out.println System.out System System.out A-1 A 1 System.out.println(B) System.out.println System.out System System.out B if(T.equals(U))
        {
            System.out.println(A);
            System.out.println(B-1);
        }
        else
            {
                System.out.println("ERROR");
            } T.equals(U) T.equals T U {
            System.out.println(A);
            System.out.println(B-1);
        } System.out.println(A) System.out.println System.out System System.out A System.out.println(B-1) System.out.println System.out System System.out B-1 B 1 {
                System.out.println("ERROR");
            } System.out.println("ERROR") System.out.println System.out System System.out "ERROR" String[] args args public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        String T = in.next();
        int A = in.nextInt();
        int B = in.nextInt();
        String U = in.next();

        if(S.equals(U))
        {
            System.out.println(A-1);
            System.out.println(B);
        }
        else if(T.equals(U))
        {
            System.out.println(A);
            System.out.println(B-1);
        }
        else
            {
                System.out.println("ERROR");
            }



    }


 } public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        String T = in.next();
        int A = in.nextInt();
        int B = in.nextInt();
        String U = in.next();

        if(S.equals(U))
        {
            System.out.println(A-1);
            System.out.println(B);
        }
        else if(T.equals(U))
        {
            System.out.println(A);
            System.out.println(B-1);
        }
        else
            {
                System.out.println("ERROR");
            }



    }


 } Main

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

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        String T = in.next();
        int A = in.nextInt();
        int B = in.nextInt();
        String U = in.next();

        if(S.equals(U))
        {
            System.out.println(A-1);
            System.out.println(B);
        }
        else if(T.equals(U))
        {
            System.out.println(A);
            System.out.println(B-1);
        }
        else
            {
                System.out.println("ERROR");
            }



    }


 }










