import java.util.Scanner;

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

    String s = sc.next();
    String t = sc.next();
    int sNum = sc.nextInt();
    int tNum = sc.nextInt();
    String tar = sc.next();

    if (tar.equals(s)) {
      String ret = Integer.toString(sNum - 1);
      System.out.println(ret + " " + tNum);
    } else {
      String ret = Integer.toString(tNum - 1);
      System.out.println(sNum + " " + ret);
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();
    int sNum = sc.nextInt();
    int tNum = sc.nextInt();
    String tar = sc.next();

    if (tar.equals(s)) {
      String ret = Integer.toString(sNum - 1);
      System.out.println(ret + " " + tNum);
    } else {
      String ret = Integer.toString(tNum - 1);
      System.out.println(sNum + " " + ret);
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();
    int sNum = sc.nextInt();
    int tNum = sc.nextInt();
    String tar = sc.next();

    if (tar.equals(s)) {
      String ret = Integer.toString(sNum - 1);
      System.out.println(ret + " " + tNum);
    } else {
      String ret = Integer.toString(tNum - 1);
      System.out.println(sNum + " " + ret);
    }
  } main {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();
    int sNum = sc.nextInt();
    int tNum = sc.nextInt();
    String tar = sc.next();

    if (tar.equals(s)) {
      String ret = Integer.toString(sNum - 1);
      System.out.println(ret + " " + tNum);
    } else {
      String ret = Integer.toString(tNum - 1);
      System.out.println(sNum + " " + ret);
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String t = sc.next(); t sc.next() sc.next sc int sNum = sc.nextInt(); sNum sc.nextInt() sc.nextInt sc int tNum = sc.nextInt(); tNum sc.nextInt() sc.nextInt sc String tar = sc.next(); tar sc.next() sc.next sc if (tar.equals(s)) {
      String ret = Integer.toString(sNum - 1);
      System.out.println(ret + " " + tNum);
    } else {
      String ret = Integer.toString(tNum - 1);
      System.out.println(sNum + " " + ret);
    } tar.equals(s) tar.equals tar s {
      String ret = Integer.toString(sNum - 1);
      System.out.println(ret + " " + tNum);
    } String ret = Integer.toString(sNum - 1); ret Integer.toString(sNum - 1) Integer.toString Integer sNum - 1 sNum 1 System.out.println(ret + " " + tNum) System.out.println System.out System System.out ret + " " + tNum ret + " " + tNum ret " " tNum {
      String ret = Integer.toString(tNum - 1);
      System.out.println(sNum + " " + ret);
    } String ret = Integer.toString(tNum - 1); ret Integer.toString(tNum - 1) Integer.toString Integer tNum - 1 tNum 1 System.out.println(sNum + " " + ret) System.out.println System.out System System.out sNum + " " + ret sNum + " " + ret sNum " " ret String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();
    int sNum = sc.nextInt();
    int tNum = sc.nextInt();
    String tar = sc.next();

    if (tar.equals(s)) {
      String ret = Integer.toString(sNum - 1);
      System.out.println(ret + " " + tNum);
    } else {
      String ret = Integer.toString(tNum - 1);
      System.out.println(sNum + " " + ret);
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();
    int sNum = sc.nextInt();
    int tNum = sc.nextInt();
    String tar = sc.next();

    if (tar.equals(s)) {
      String ret = Integer.toString(sNum - 1);
      System.out.println(ret + " " + tNum);
    } else {
      String ret = Integer.toString(tNum - 1);
      System.out.println(sNum + " " + ret);
    }
  }
} Main
import java.util.Scanner;

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

    String s = sc.next();
    String t = sc.next();
    int sNum = sc.nextInt();
    int tNum = sc.nextInt();
    String tar = sc.next();

    if (tar.equals(s)) {
      String ret = Integer.toString(sNum - 1);
      System.out.println(ret + " " + tNum);
    } else {
      String ret = Integer.toString(tNum - 1);
      System.out.println(sNum + " " + ret);
    }
  }
}
