function Main (input) {
  input = input.split("\n").map(inp => inp.split(" "));
  var S, T, A, B, U;
  S = input[0][0];
  T = input[0][1];
  A = parseInt(input[1][0], 10);
  B = parseInt(input[1][1], 10);
  U = input[2][0];
  if (U == S) {
    A--;
  }
  else if (U == T) {
    B--;
  }
  console.log("%d %d", A, B);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));