Buggy python submission (verdict: Runtime Error):
sb = list(input())
sc = list(input())

d = sa[0]

while 1:
    if d == 'a':
        sa = sa.pop(0)
        if sa == []:
            print('A')
            break
        d = sa[0]
    elif d == 'b':
        sb = sb.pop(0)
        if sb == []:
            print('B')
            break
        d = sb[0]
    else:
        sc = sc.pop(0)
        if sc == []:
            print('C')
            break
        d = sc[0]

Fixed submission:
sa = list(input())
sb = list(input())
sc = list(input())

d = 'a'
cnta = 0
cntb = 0
cntc = 0
A = len(sa)
B = len(sb)
C = len(sc)

while 1:
    if d == 'a':
        cnta += 1
        if cnta == A+1:
            print('A')
            break
        d = sa.pop(0)
    elif d == 'b':
        cntb += 1
        if cntb == B+1:
            print('B')
            break
        d = sb.pop(0)
    else:
        cntc += 1
        if cntc == C+1:
            print('C')
            break
        d = sc.pop(0)

Buggy python submission (verdict: Runtime Error):
sa = list(input())
sb = list(input())
sc = list(input())

d = sa[0]

while (len(sa) == 0 or len(sb) == 0 or len(sc) == 0) == 0:
    if d == 'a':
        sa = sa[1::]
        d = sa[0]
    elif d == 'b':
        sb = sb[1::]
        d = sb[0]
    else:
        sc = sc[1::]
        d = sc[0]

if len(sa) == 0:
    print('A')
elif len(sb) == 0:
    print('B')
else:
    print('C')

Fixed submission:
sa = list(input())
sb = list(input())
sc = list(input())

d = 'a'
cnta = 0
cntb = 0
cntc = 0
A = len(sa)
B = len(sb)
C = len(sc)

while 1:
    if d == 'a':
        cnta += 1
        if cnta == A+1:
            print('A')
            break
        d = sa.pop(0)
    elif d == 'b':
        cntb += 1
        if cntb == B+1:
            print('B')
            break
        d = sb.pop(0)
    else:
        cntc += 1
        if cntc == C+1:
            print('C')
            break
        d = sc.pop(0)

Buggy python submission (verdict: Runtime Error):
sa = list(input())
sb = list(input())
sc = list(input())

d = sa[0]

while d !=[]:
    if d == 'a':
        sa = sa[1::]
        d = sa[0]
    elif d == 'b':
        sb = sb[1::]
        d = sb[0]
    else:
        sc = sc[1::]
        d = sc[0]

if len(sa) == 0:
    print('A')
elif len(sb) == 0:
    print('B')
else:
    print('C')

Fixed submission:
sa = list(input())
sb = list(input())
sc = list(input())

d = 'a'
cnta = 0
cntb = 0
cntc = 0
A = len(sa)
B = len(sb)
C = len(sc)

while 1:
    if d == 'a':
        cnta += 1
        if cnta == A+1:
            print('A')
            break
        d = sa.pop(0)
    elif d == 'b':
        cntb += 1
        if cntb == B+1:
            print('B')
            break
        d = sb.pop(0)
    else:
        cntc += 1
        if cntc == C+1:
            print('C')
            break
        d = sc.pop(0)

Buggy python submission (verdict: Runtime Error):
sa = list(input())
sb = list(input())
sc = list(input())

d = sa[0]

while (len(sa) == 0 or len(sb) == 0 or len(sc) == 0) == 0:
    if d == 'a':
        sa = sa[1::]
        d = sa[0]
    elif d == 'b':
        sb = sb[1::]
        d = sb[0]
    else:
        sc = sc[1::]
        d = sc[0]

if len(sa) == 0:
    print('A')
elif len(sb) == 0:
    print('B')
else:
    print('C')

Fixed submission:
sa = list(input())
sb = list(input())
sc = list(input())

d = 'a'
cnta = 0
cntb = 0
cntc = 0
A = len(sa)
B = len(sb)
C = len(sc)

while 1:
    if d == 'a':
        cnta += 1
        if cnta == A+1:
            print('A')
            break
        d = sa.pop(0)
    elif d == 'b':
        cntb += 1
        if cntb == B+1:
            print('B')
            break
        d = sb.pop(0)
    else:
        cntc += 1
        if cntc == C+1:
            print('C')
            break
        d = sc.pop(0)

Buggy python submission (verdict: Runtime Error):
sa = list(input())
sb = list(input())
sc = list(input())

cnta = len(sa)
cntb = len(sb)
cntc = len(sc)

d = sa[0]

while not(cnta == 0 or cntb == 0 or cntc == 0):
    if d == 'a':
        sa = sa[1::]
        d = sa[0]
    elif d == 'b':
        sb = sb[1::]
        d = sb[0]
    else:
        sc = sc[1::]
        d = sc[0]
if cnta == 0:
    print('A')
elif cntb == 0:
    print('B')
else:
    print('C')

Fixed submission:
sa = list(input())
sb = list(input())
sc = list(input())

d = 'a'
cnta = 0
cntb = 0
cntc = 0
A = len(sa)
B = len(sb)
C = len(sc)

while 1:
    if d == 'a':
        cnta += 1
        if cnta == A+1:
            print('A')
            break
        d = sa.pop(0)
    elif d == 'b':
        cntb += 1
        if cntb == B+1:
            print('B')
            break
        d = sb.pop(0)
    else:
        cntc += 1
        if cntc == C+1:
            print('C')
            break
        d = sc.pop(0)