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 A = sc.nextInt();
      int B = sc.nextInt();
      String u = sc.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);
      }
    }
} 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 A = sc.nextInt();
      int B = sc.nextInt();
      String u = sc.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);
      }
    }
} Main public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      String s = sc.next();
      String t = sc.next();
      
      int A = sc.nextInt();
      int B = sc.nextInt();
      String u = sc.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);
      }
    } main {
    
    Scanner sc = new Scanner(System.in);
      
      String s = sc.next();
      String t = sc.next();
      
      int A = sc.nextInt();
      int B = sc.nextInt();
      String u = sc.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);
      }
    } 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 A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc String u = sc.next(); u sc.next() sc.next sc 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);
      } 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);
      } 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 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 A = sc.nextInt();
      int B = sc.nextInt();
      String u = sc.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);
      }
    }
} public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      String s = sc.next();
      String t = sc.next();
      
      int A = sc.nextInt();
      int B = sc.nextInt();
      String u = sc.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);
      }
    }
} 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 A = sc.nextInt();
      int B = sc.nextInt();
      String u = sc.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);
      }
    }
}