For this Question: You are given three string A, B, C consisting of only characters 'a', 'b' and 'c'. You need to follow the given procedure:
-> Initially start with string A.
-> At each turn, if the current string contains atleast 1 character, remove the first character. Now if the removed character is a, turn goes to string A. Similarly b -> B, and c -> C.
-> If the current string has no character, output the string name.

Note: The length of the strings maybe different

See sample for better understanding.The input consists of 3 lines containing strings A, B, C.

Constraints
1 <= |A|, |B|, |C| <= 1000

Output a single character A or B or C.Sample Input
aca
accc
ca

Sample Output
A

Explanation
Initially its turn of string A. Its first character is a, 'a' gets removed from the string. The turn goes to A. Now its first character is 'c', 'c' gets removed from the string. The turn goes to C. Now its first character is 'c', 'c' gets removed from the string. The turn goes to C. Now its first character is 'a', 'a' gets removed from the string. The turn goes to A. Now its first character is 'a', 'a' gets removed from the string. The turn goes to A.
Since string A is empty, the answer is A.  , I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static void main (String[] args) {

        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        int sizeA = A.length();
        int sizeB = B.length();
        int sizeC = C.length();

        int i=0,j=0,k=0;
        int select = 1;
        int flagA=0,flagB=0,flagC=0;
        while(i<sizeA && j<sizeB && k<sizeC){


            if(select == 1){
                if(flagA == 1){
                    select = 1;
                    break;
                }

                ++i;
                if(A.charAt(i-1) == 'b')
                    select = 2;
                else if(A.charAt(i-1) == 'c')
                    select = 3;
                if(i == sizeA && select != 1){
                    flagA = 1;
                    --i;
                }
            }else if(select == 2){
                if(flagB == 1){
                    select = 2;
                    break;
                }
                ++j;
                if(B.charAt(j-1) == 'a')
                    select = 1;
                else if(B.charAt(j-1) == 'c')
                    select = 3;
                if(j == sizeB && select != 2){
                    flagB = 1;
                    --j;
                }
            }else{
                if(flagC == 1){
                    select = 3;
                    break;
                }
                ++k;
                if(C.charAt(k-1) == 'a')
                    select = 1;
                else if(C.charAt(k-1) == 'b')
                    select = 2;
                if(k == sizeC && select != 3){
                    flagC = 1;
                    --k;
                }
            }
        }
        if(select == 1)
            System.out.println("A");
        else if(select == 2)
            System.out.println("B");
        else
            System.out.println("C");






    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?