For this Question: 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.
Alice has two boxes. One contains A cubes with the string S written and other contains B cubes with the string T written.
From these two boxes, Alice chooses one with the string U written on it and throws it away.
Find the number of cubes in each of the box.The first line contains two strings S and T.
The second line contains two integers A and B.
The third line contains a single integer U.

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!=T
S=U or T=U.
1≤A, B≤10
A and B are integers.Find the number of cubes in each of the box.Sample Input 1:
red blue
3 4
red

Sample Output 1:
2 4

Explanation: Alice chose a cube with red written on it and threw it away. Now we have two cubes with the string S and four cubes with the string T.
 
Sample Input 2:
red blue
5 5
blue

Sample Output 2:
5 4

Explanation: Alice chose a cube with blue written on it and threw it away. Now we have five cubes with the string S and four cubes with the string T., I have written this Solution Code: 



import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Math.*;
import static java.lang.System.out;

public class Main {



    void solve() {
        String s= in.next();
        String t= in.next();
        int a= in.nextInt();
        int b= in.nextInt();
        String u= in.next();
        if(s.equals(u)){
            a--;
        }
        if(t.equals(u)){
            b--;
        }

        sb.append(a).append(" ").append(b).append("\n");
    }

    int util(int[] pos, int j) {
        int cnt=0;
        int p=j;
        while(p!=-1) {
            cnt++;
            p=pos[p];
            if(p==j) return cnt;
        }
        return -1;
    }


    void start(){
        sb= new StringBuffer();


            solve();

        out.print(sb);
    }


    FastReader in;
    StringBuffer sb;
    public static void main(String[] args) {
        new Main().run();
    }
    void run(){
        in= new FastReader();
        start();
    }

    long nCr(int n, int r) {
        if (r > n)
            return 0;
        long  m = 1000000007;
        long[] inv = new long[r + 1];
        inv[0] = 1;
        if(r+1>=2)
            inv[1] = 1;

        for (int i = 2; i <= r; i++) {
            inv[i] = m - (m / i) * inv[(int) (m % i)] % m;
        }

        long ans = 1;

        for (int i = 2; i <= r; i++) {
            ans = (int) (((ans % m) * (inv[i] % m)) % m);
        }

        for (int i = n; i >= (n - r + 1); i--) {
            ans = (int) (((ans % m) * (i % m)) % m);
        }
        return ans;
    }

    int lower_bound(ArrayList<Integer> a, int x) {
        int l=-1,r=a.size();
        while(l+1<r) {
            int m=(l+r)>>>1;
            if(a.get(m)>=x) r=m;
            else l=m;
        }
        return r;
    }

    void bubbleSort(long[] arr){
        int n= arr.length;

        for(int i=n-1; i>0; i--){
            for(int j=0; j<i; j++){
                if(arr[i] < arr[j]){
                    swap(arr, i, j);
                }
            }
        }
    }

    void swap(long[] arr, int i, int j){
        long temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }

    long numberOfWays(long n, long k) {

        if (n == 0)
            return 1;
        if (k == 0)
            return 1;

        if (n >= (int)Math.pow(2, k)) {
            int curr_val = (int)Math.pow(2, k);
            return numberOfWays(n - curr_val, k)
                    + numberOfWays(n, k - 1);
        }
        else
            return numberOfWays(n, k - 1);
    }

    boolean palindrome(String s){
        int i=0, j= s.length()-1;
        while(i<j){
            if(s.charAt(i)!=s.charAt(j)) return false;

            i++; j--;
        }

        return true;
    }


    int call(int[] A, int N, int K) {

        int i = 0, j = 0, sum = 0;
        int maxLen = Integer.MIN_VALUE;

        while (j < N) {
            sum += A[j];
            if (sum < K) {
                j++;
            }
            else if (sum == K) {
                maxLen = Math.max(maxLen, j-i+1);
                j++;
            }
            else if (sum > K) {
                while (sum > K) {
                    sum -= A[i];
                    i++;
                }
                if(sum == K){
                    maxLen = Math.max(maxLen, j-i+1);
                }
                j++;
            }
        }
        return maxLen;
    }

    int largestNum(int n)
    {
        int num = 0;


        for (int i = 0; i <= 32; i++)
        {

            int x = (1 << i);

            if ((x - 1) >= n)
                num = (1 << i) - 1;

            else
                break;
        }


        return num;
    }

    static boolean isPrime(int n)
    {

        if (n <= 1)
            return false;


        for (int i = 2; i <= sqrt(n); i++)
            if (n % i == 0)
                return false;

        return true;
    }








    int call(int i,int j, int[][] mat, int[][] dp){
        int m= mat.length;
        int n= mat[0].length;
        if(i>=m || j>=n){
            return Integer.MIN_VALUE;
        }

        if(i==m-1 && j==n-1){
            return mat[i][j];
        }

        if(dp[i][j] != -1){
            return dp[i][j];
        }

        return dp[i][j] = max(call(i+1, j, mat, dp), call(i, j+1, mat, dp)) + mat[i][j];
    }

    int util(int i,int j, int[][] mat, int[][] dp){
        int m= mat.length;
        int n= mat[0].length;
        if(i>=m || j>=n){
            return Integer.MAX_VALUE;
        }

        if(i==m-1 && j==n-1){
            return mat[i][j];
        }

        if(dp[i][j] != -1){
            return dp[i][j];
        }

        return dp[i][j] = min(util(i+1, j, mat, dp), util(i, j+1, mat, dp)) + mat[i][j];
    }

    long power(long x, long y, long p) {
        long res = 1;
        x = x % p;
        while (y > 0) {
            if (y % 2 == 1)
                res = (res * x) % p;

            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }



    int lower_bound(long[] a, long x) {
        int l=-1,r=a.length;
        while(l+1<r) {
            int m=(l+r)>>>1;
            if(a[m]>=x) r=m;
            else l=m;
        }
        return r;
    }
    int upper_bound(ArrayList<Integer> arr, int key) {
        int i=0, j=arr.size()-1;
        if(j==-1){
            return 0;
        }
        if (arr.get(j)<=key) return j+1;
        if(arr.get(i)>key) return i;
        while (i<j){
            int mid= (i+j)/2;
            if(arr.get(mid)<=key){
                i= mid+1;
            }else{
                j=mid;
            }
        }
        return i;
    }
    void sort(long[] A){
        int n = A.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            long tmp = A[i];
            int randomPos = i + rnd.nextInt(n-i);
            A[i] = A[randomPos];
            A[randomPos] = tmp;
        }
        Arrays.sort(A);
    }
    int[] intArr(int n){
        int[] res= new int[n];
        for(int i=0;i<n;i++){
            res[i]= in.nextInt();
        }
        return res;
    }
    long[] longArr(int n){
        long[] res= new long[n];
        for(int i=0;i<n;i++){
            res[i]= in.nextLong();
        }
        return res;
    }

    long MAX= 100000000;
    int[] precomp;
    void sieve(){
        long n= MAX;
        precomp = new int[(int) (n+1)];
        boolean[] prime = new boolean[(int) (n+1)];
        for(int i=0;i<=n;i++)
            prime[i] = true;

        for(long p = 2; p*p <=n; p++)
        {

            if(prime[(int) p])
            {

                for(long i = p*p; i <= n; i += p)
                    prime[(int) i] = false;
            }
        }


        for(long i = 2; i <= n; i++)
        {
            if(prime[(int) i])
                precomp[(int) i]= 1;
        }
    }

    long REVERSE(long N) {

        long rev=0;
        long org= N;
        while (N!=0){
            long d= N%10;
            rev = rev*10 +d;
            N /= 10;
        }
        return rev;
    }
    long sumOfDigits(String n){
        long sum= 0;
        for (char c: n.toCharArray()){
            sum += Integer.parseInt(String.valueOf(c));
        }
        return sum;
    }
    long[] revArray(long[] arr) {
        int n= arr.length;
        int i=0, j=n-1;
        while (i<j){
            long temp= arr[i];
            arr[i]= arr[j];
            arr[j]= temp;
            i++;
            j--;
        }
        return arr;
    }
    long gcd(long a, long b){
        if (b==0)
            return a;
        return gcd(b, a%b);
    }
    long lcm(long a,long b){
        return (a*b)/gcd(a,b);
    }
    static class Pair implements Comparable<Pair>{
        long first;
        long second;
        Pair(long x, long y){
            this.first=x;
            this.second=y;
        }

        @Override
        public int compareTo(Pair o) {
            return 0;
        }
    }










    public static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br=new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while (st==null || !st.hasMoreElements()){
                try{
                    st=new StringTokenizer(br.readLine());
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
        long nextLong(){
            return Long.parseLong(next());
        }
        double nextDouble(){
            return Double.parseDouble(next());
        }
        float nextFloat(){
            return Float.parseFloat(next());
        }
        String nextLine(){
            String str="";
            try{
                str=br.readLine();
            }catch (Exception e){
                e.printStackTrace();
            }
            return str;
        }
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?