type ball_t = {
  word : string;
  number : int;
}

let balls s_type t_type u =
  match s_type with {word = s_w; number = s_n}
    -> match t_type with {word = t_w; number = t_n}
      -> if s_w = u then (s_n - 1, t_n) else (s_n, t_n -1)

let s, t = Scanf.sscanf (read_line ()) "%s %s" (fun s t -> (s, t))
let a, b = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))
let s_type = {word = s; number = a}
let t_type = {word = t; number = b}
let u = read_line ()

let () = let ans_s, ans_t = balls s_type t_type u in
  Printf.printf "%d %d\n" ans_s ans_t