import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String Red=sc.next();
    String Blue=sc.next();
    int N=sc.nextInt();
    int M=sc.nextInt();
    String Ball=sc.next();
    
    if(Ball.equals(Red)) System.out.print((N-1)+" "+M);
    if(Ball.equals(Blue)) System.out.print(N+" "+(M-1));
  }
} import java.util.*; util.* java class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String Red=sc.next();
    String Blue=sc.next();
    int N=sc.nextInt();
    int M=sc.nextInt();
    String Ball=sc.next();
    
    if(Ball.equals(Red)) System.out.print((N-1)+" "+M);
    if(Ball.equals(Blue)) System.out.print(N+" "+(M-1));
  }
} Main public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String Red=sc.next();
    String Blue=sc.next();
    int N=sc.nextInt();
    int M=sc.nextInt();
    String Ball=sc.next();
    
    if(Ball.equals(Red)) System.out.print((N-1)+" "+M);
    if(Ball.equals(Blue)) System.out.print(N+" "+(M-1));
  } main {
    Scanner sc=new Scanner(System.in);
    String Red=sc.next();
    String Blue=sc.next();
    int N=sc.nextInt();
    int M=sc.nextInt();
    String Ball=sc.next();
    
    if(Ball.equals(Red)) System.out.print((N-1)+" "+M);
    if(Ball.equals(Blue)) System.out.print(N+" "+(M-1));
  } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String Red=sc.next(); Red sc.next() sc.next sc String Blue=sc.next(); Blue sc.next() sc.next sc int N=sc.nextInt(); N sc.nextInt() sc.nextInt sc int M=sc.nextInt(); M sc.nextInt() sc.nextInt sc String Ball=sc.next(); Ball sc.next() sc.next sc if(Ball.equals(Red)) System.out.print((N-1)+" "+M); Ball.equals(Red) Ball.equals Ball Red System.out.print((N-1)+" "+M) System.out.print System.out System System.out (N-1)+" "+M (N-1)+" "+M (N-1) N 1 " " M if(Ball.equals(Blue)) System.out.print(N+" "+(M-1)); Ball.equals(Blue) Ball.equals Ball Blue System.out.print(N+" "+(M-1)) System.out.print System.out System System.out N+" "+(M-1) N+" "+(M-1) N " " (M-1) M 1 String[] args args
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String Red=sc.next();
    String Blue=sc.next();
    int N=sc.nextInt();
    int M=sc.nextInt();
    String Ball=sc.next();
    
    if(Ball.equals(Red)) System.out.print((N-1)+" "+M);
    if(Ball.equals(Blue)) System.out.print(N+" "+(M-1));
  }
}
