Buggy python submission (verdict: Runtime Error):
Sa, Sb, Sc = open(0).read().split()
#print(Sa, Sb,Sc)
numSa = len(Sa)
numSb = len(Sb)
numSc = len(Sc)
#print(numSa,numSb,numSc)
i=j=k=0
flgA = True
flgB = flgC = False
l=0
while(True):
    if flgA == True:
        #print("A",i)
        flgA = False
        i+=1
        if numSa==i:
            print("A")
            break
        if Sa[i] == "a":
            flgA = True
        elif Sa[i] == "b":
            flgB = True
        else:
            flgC = True
    elif flgB == True:
        #print("B",j)
        flgB = False
        j+=1
        if numSb==j:
            pritn("B")
            break
        if Sb[j] == "a":
            flgA = True
        elif Sb[j] == "b":
            flgB = True
        else:
            flgC = True
    elif flgC == True:
       #print("C",k)
        flgC = False
        k+=1
        if numSc==k:
            print("C")
            break
        if Sc[k] == "a":
            flgA = True
        elif Sc[k] == "b":
            flgB = True
        else:
            flgC = True
    else:
        pass
    #print(l,"::",Sa[i],i,Sb[j],j,Sc[k],k)
        
    l+=1

Fixed submission:
Sa, Sb, Sc = open(0).read().split()
# print(Sa, Sb,Sc)
numSa = len(Sa)
numSb = len(Sb)
numSc = len(Sc)
# print(numSa,numSb,numSc)
i=j=k=0
flgA = True
flgB = flgC = False
l=0
# noDebug = False
while(True):
    if flgA == True:
#         print("A",i)
        flgA = False
        if numSa==i:
             print("A")
#             noDebug = True
             break
        if Sa[i] == "a":
            flgA = True
        elif Sa[i] == "b":
            flgB = True
        else:
            flgC = True
        i+=1
    elif flgB == True:
#         print("B",j)
        flgB = False
        if numSb==j:
            print("B")
#             noDebug = True
            break
        if Sb[j] == "a":
            flgA = True
        elif Sb[j] == "b":
            flgB = True
        else:
            flgC = True
        j+=1
    elif flgC == True:
#         print("C",k)
        flgC = False
        if numSc==k:
            print("C")
#             noDebug = True
            break
        if Sc[k] == "a":
            flgA = True
        elif Sc[k] == "b":
            flgB = True
        else:
            flgC = True
        k+=1
    else:
        pass
#     if noDebug == False:
#         print(l)
#         print(l,"::",Sa[i],i,Sb[j],j,Sc[k],k) 
#     l+=1

Buggy python submission (verdict: Runtime Error):
Sa, Sb, Sc = open(0).read().split()
#print(Sa, Sb,Sc)
numSa = len(Sa)
numSb = len(Sb)
numSc = len(Sc)
i=j=k=0
flgA = True
flgB = flgC = False
while(True):
    if flgA == True:
        flgA = False
        if Sa[i] == "a":
            i+=1
            flgA = True
        elif Sa[i] == "b":
            j+=1
            flgB = True
        else:
            k+=1
            flgC = True
    elif flgB == True:
        flgB = False
        if Sb[j] == "a":
            i+=1
            flgA = True
        elif Sb[j] == "b":
            j+=1
            flgB = True
        else:
            k+=1
            flgC = True
    elif flgC == True:
        flgC = False
        if Sc[k] == "a":
            i+=1
            flgA = True
        elif Sc[k] == "b":
            j+=1
            flgB = True
        else:
            k+=1
            flgC = True
    else:
        pass
    
    if numSa==i:
        print("A")
        break
    elif numSb==j:
        pritn("B")
        break
    elif numSc==k:
        print("C")
        break
    else:
        pass

Fixed submission:
Sa, Sb, Sc = open(0).read().split()
# print(Sa, Sb,Sc)
numSa = len(Sa)
numSb = len(Sb)
numSc = len(Sc)
# print(numSa,numSb,numSc)
i=j=k=0
flgA = True
flgB = flgC = False
l=0
# noDebug = False
while(True):
    if flgA == True:
#         print("A",i)
        flgA = False
        if numSa==i:
             print("A")
#             noDebug = True
             break
        if Sa[i] == "a":
            flgA = True
        elif Sa[i] == "b":
            flgB = True
        else:
            flgC = True
        i+=1
    elif flgB == True:
#         print("B",j)
        flgB = False
        if numSb==j:
            print("B")
#             noDebug = True
            break
        if Sb[j] == "a":
            flgA = True
        elif Sb[j] == "b":
            flgB = True
        else:
            flgC = True
        j+=1
    elif flgC == True:
#         print("C",k)
        flgC = False
        if numSc==k:
            print("C")
#             noDebug = True
            break
        if Sc[k] == "a":
            flgA = True
        elif Sc[k] == "b":
            flgB = True
        else:
            flgC = True
        k+=1
    else:
        pass
#     if noDebug == False:
#         print(l)
#         print(l,"::",Sa[i],i,Sb[j],j,Sc[k],k) 
#     l+=1

Buggy python submission (verdict: Runtime Error):
Sa, Sb, Sc = open(0).read().split()
print(Sa, Sb,Sc)
numSa = len(Sa)
numSb = len(Sb)
numSc = len(Sc)
i=j=k=0
flgA = True
flgB = flgC = False
while(True):
    if flgA == True:
        flgA = False
        if Sa[i] == "a":
            i+=1
            flgA = True
        elif Sa[i] == "b":
            j+=1
            flgB = True
        else:
            k+=1
            flgC = True
    elif flgB == True:
        flgB = False
        if Sb[j] == "a":
            i+=1
            flgA = True
        elif Sb[j] == "b":
            j+=1
            flgB = True
        else:
            k+=1
            flgC = True
    elif flgC == True:
        flgC = False
        if Sc[k] == "a":
            i+=1
            flgA = True
        elif Sc[k] == "b":
            j+=1
            flgB = True
        else:
            k+=1
            flgC = True
    else:
        pass
    
    if numSa==i:
        print("A")
        break
    elif numSb==j:
        pritn("B")
        break
    elif numSc==k:
        print("C")
        break
    else:
        pass

Fixed submission:
Sa, Sb, Sc = open(0).read().split()
# print(Sa, Sb,Sc)
numSa = len(Sa)
numSb = len(Sb)
numSc = len(Sc)
# print(numSa,numSb,numSc)
i=j=k=0
flgA = True
flgB = flgC = False
l=0
# noDebug = False
while(True):
    if flgA == True:
#         print("A",i)
        flgA = False
        if numSa==i:
             print("A")
#             noDebug = True
             break
        if Sa[i] == "a":
            flgA = True
        elif Sa[i] == "b":
            flgB = True
        else:
            flgC = True
        i+=1
    elif flgB == True:
#         print("B",j)
        flgB = False
        if numSb==j:
            print("B")
#             noDebug = True
            break
        if Sb[j] == "a":
            flgA = True
        elif Sb[j] == "b":
            flgB = True
        else:
            flgC = True
        j+=1
    elif flgC == True:
#         print("C",k)
        flgC = False
        if numSc==k:
            print("C")
#             noDebug = True
            break
        if Sc[k] == "a":
            flgA = True
        elif Sc[k] == "b":
            flgB = True
        else:
            flgC = True
        k+=1
    else:
        pass
#     if noDebug == False:
#         print(l)
#         print(l,"::",Sa[i],i,Sb[j],j,Sc[k],k) 
#     l+=1