Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
	string A,B,C,D={};
  	cin >> A >> B >> C;	
  	D=A;
  	while(A!={} && (B!={} && C!={})){
    	if(D==A){
          	if(A[0]==a){
            	A = A.substr(1,A.size()-1);
              	D = A;
            }
          	else if(A[0]==b){
            	A = A.substr(1,A.size()-1);
              	D = B;
            }
          	else if(A[0]==c){
            	A = A.substr(1,A.size()-1);
              	D = C;
            }
        	
          
        }
      	if(D==B){
          	if(B[0]==a){
            	B = B.substr(1,B.size()-1);
              	D = A;
            }
          	else if(B[0]==b){
            	B = B.substr(1,B.size()-1);
              	D = B;
            }
          	else if(B[0]==c){
            	B = B.substr(1,B.size()-1);
              	D = C;
            }
        	
          
        }
      	if(D==C){
          	if(C[0]==a){
            	C = C.substr(1,C.size()-1);
              	D = A;
            }
          	else if(C[0]==b){
            	C = C.substr(1,C.size()-1);
              	D = B;
            }
          	else if(C[0]==c){
            	C = C.substr(1,C.size()-1);
              	D = C;
            }
        	
          
        }
      	
    }
  	if(A=={}) cout << "A" << endl;
  	else if(B=={}) cout << "B" endl;
  	else if(C=={}) cout << "C" endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:18: error: expected primary-expression before '{' token
    8 |         while(A!={} && (B!={} && C!={})){
      |                  ^
a.cc:8:18: error: expected ')' before '{' token
    8 |         while(A!={} && (B!={} && C!={})){
      |              ~   ^
      |                  )
a.cc:8:24: error: expected identifier before '(' token
    8 |         while(A!={} && (B!={} && C!={})){
      |                        ^
a.cc:8:37: error: expected primary-expression before '{' token
    8 |         while(A!={} && (B!={} && C!={})){
      |                                     ^
a.cc:8:39: error: expected primary-expression before ')' token
    8 |         while(A!={} && (B!={} && C!={})){
      |                                       ^
a.cc:59:15: error: expected primary-expression before '{' token
   59 |         if(A=={}) cout << "A" << endl;
      |               ^
a.cc:59:15: error: expected ')' before '{' token
   59 |         if(A=={}) cout << "A" << endl;
      |           ~   ^
      |               )
a.cc:60:20: error: expected primary-expression before '{' token
   60 |         else if(B=={}) cout << "B" endl;
      |                    ^
a.cc:60:20: error: expected ')' before '{' token
   60 |         else if(B=={}) cout << "B" endl;
      |                ~   ^
      |                    )
a.cc:60:35: error: expected ';' before 'endl'
   60 |         else if(B=={}) cout << "B" endl;
      |                                   ^~~~~
      |                                   ;
a.cc:61:20: error: expected primary-expression before '{' token
   61 |         else if(C=={}) cout << "C" endl;
      |                    ^
a.cc:61:20: error: expected ')' before '{' token
   61 |         else if(C=={}) cout << "C" endl;
      |                ~   ^
      |                    )
a.cc:61:35: error: expected ';' before 'endl'
   61 |         else if(C=={}) cout << "C" endl;
      |                                   ^~~~~
      |                                   ;
a.cc:8:34: error: label 'C' used but not defined
    8 |         while(A!={} && (B!={} && C!={})){
      |                                  ^