import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc154_a solver = new abc154_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc154_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int A = in.nextInt();
            int B = in.nextInt();
            String U = in.next();
            if (S.compareTo(U) == 0) {
                A--;
            }
            if (T.compareTo(U) == 0) {
                B--;
            }
            out.println(A + " " + B);
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc154_a solver = new abc154_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc154_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int A = in.nextInt();
            int B = in.nextInt();
            String U = in.next();
            if (S.compareTo(U) == 0) {
                A--;
            }
            if (T.compareTo(U) == 0) {
                B--;
            }
            out.println(A + " " + B);
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc154_a solver = new abc154_a();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc154_a solver = new abc154_a();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) abc154_a solver = new abc154_a(); solver new abc154_a() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class abc154_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int A = in.nextInt();
            int B = in.nextInt();
            String U = in.next();
            if (S.compareTo(U) == 0) {
                A--;
            }
            if (T.compareTo(U) == 0) {
                B--;
            }
            out.println(A + " " + B);
        }

    } abc154_a public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int A = in.nextInt();
            int B = in.nextInt();
            String U = in.next();
            if (S.compareTo(U) == 0) {
                A--;
            }
            if (T.compareTo(U) == 0) {
                B--;
            }
            out.println(A + " " + B);
        } solve {
            String S = in.next();
            String T = in.next();
            int A = in.nextInt();
            int B = in.nextInt();
            String U = in.next();
            if (S.compareTo(U) == 0) {
                A--;
            }
            if (T.compareTo(U) == 0) {
                B--;
            }
            out.println(A + " " + B);
        } 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.compareTo(U) == 0) {
                A--;
            } S.compareTo(U) == 0 S.compareTo(U) S.compareTo S U 0 {
                A--;
            } A-- A if (T.compareTo(U) == 0) {
                B--;
            } T.compareTo(U) == 0 T.compareTo(U) T.compareTo T U 0 {
                B--;
            } B-- B out.println(A + " " + B) out.println out A + " " + B A + " " + B A " " B int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc154_a solver = new abc154_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc154_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int A = in.nextInt();
            int B = in.nextInt();
            String U = in.next();
            if (S.compareTo(U) == 0) {
                A--;
            }
            if (T.compareTo(U) == 0) {
                B--;
            }
            out.println(A + " " + B);
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc154_a solver = new abc154_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc154_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int A = in.nextInt();
            int B = in.nextInt();
            String U = in.next();
            if (S.compareTo(U) == 0) {
                A--;
            }
            if (T.compareTo(U) == 0) {
                B--;
            }
            out.println(A + " " + B);
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc154_a solver = new abc154_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc154_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int A = in.nextInt();
            int B = in.nextInt();
            String U = in.next();
            if (S.compareTo(U) == 0) {
                A--;
            }
            if (T.compareTo(U) == 0) {
                B--;
            }
            out.println(A + " " + B);
        }

    }
}

