We have A balls with the string S written on each of them and B balls with the string T…
- User
We have A balls with the string S written on each of them and B balls with the string T written on each of them. From these balls, Takahashi chooses one with the string U written on it and throws it away. Find the number of balls with the string S and balls with the string T that we have now.
Constraints
- S, T, and U are strings consisting of lowercase English letters.
- The lengths of S and T are each between 1 and 10 (inclusive).
- S \not= T
- S=U or T=U.
- 1 \leq A,B \leq 10
- A and B are integers. Input
Input is given from Standard Input in the following format:
S T A B U
Output
Print the answer, with space in between.
Examples
Input
red blue 3 4 red
Output
2 4
Input
red blue 5 5 blue
Output
5 4
Assistant
We need to parse the problem.
We have A balls with string S on each, and B balls with string T. Takahashi chooses one ball with string U and discards it. So if U equals S, then we decrement A by 1; if U equals T, we decrement B by 1. Then output the new counts.
Constraints: S, T, U are strings, lengths between 1 and 10, S != T, and U is either S or T. So indeed only one of them matches.
A and B are between 1 and 10.
So solution: read S and T as strings. Read A and B as integers. Read U. If U == S: print (A-1, B). else if U == T: print (A, B-1).
Examples: First: S="red", T="blue", A=3, B=4, U="red" -> output "2 4". Second: S="red", T="blue", A=5, B=5, U="blue" -> output "5 4".
Implementation straightforward.
Edge cases: None.
Thus answer is simple.
I'll produce a Python code:
def main(): import sys data = sys.stdin.read().split() S = data[0] T = data[1] A = int(data[2]) B = int(data[3]) U = data[4] if U == S: A -= 1 elif U == T: B -= 1 print(A, B)
Yes. Also, could do via input() lines.
Thus final answer. ```python
import sys
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.