      PROGRAM piyo
      IMPLICIT NONE
      character(10) :: s,t,u
      integer :: a,b
      
      read*,s,t
      read*,a,b
      read*,u
      
      
      if( trim(s)==trim(u) ) a = a - 1
      if( trim(t)==trim(u) ) b = b - 1
      
      print*, max(0,a),max(0,b)

      
      END PROGRAM