qyliang/CodeNanoFix huggingface dataset:
Buggy code:
# -*- coding: utf-8 -*-
from sys import stdin
stdin = open("sample.txt")

A = stdin.readline().rstrip()
B = stdin.readline().rstrip()
C = stdin.readline().rstrip()
turn = "a"

for i in range(300):
    if turn == "a":
        if A != "":
            turn = A[0]
            A = A[1:]
        else:
            print("A")
            exit()
    elif turn == "b":
        if B != "":
            turn = B[0]
            B = B[1:]
        else:
            print("B")
            exit()
    elif turn == "c":
        if C != "":
            turn = C[0]
            C = C[1:]
        else:
            print("C")
            exit()

Fixed code:
# -*- coding: utf-8 -*-
from sys import stdin

A = stdin.readline().rstrip()
B = stdin.readline().rstrip()
C = stdin.readline().rstrip()
turn = "a"

for i in range(300):
    if turn == "a":
        if A != "":
            turn = A[0]
            A = A[1:]
        else:
            print("A")
            exit()
    elif turn == "b":
        if B != "":
            turn = B[0]
            B = B[1:]
        else:
            print("B")
            exit()
    elif turn == "c":
        if C != "":
            turn = C[0]
            C = C[1:]
        else:
            print("C")
            exit()
Buggy code:
import sys
input = sys.stdin.readline
a = [list(input())[: -1] for _ in range(3)]
for i in range(3): a[i].reverse()
x = 0
c = ["a", "b", "c"]
while True:
  t = a[x].pop()
  for i in range(3):
    if t == c[i]:
      x = i
      break
  if len(a[0]) == 0:
    print("A")
    break
  elif len(a[1]) == 0:
    print("B")
    break
  elif len(a[2]) == 0:
    print("C")
    break

Fixed code:
import sys
input = sys.stdin.readline
a = [list(input())[: -1] for _ in range(3)]
for i in range(3): a[i].reverse()
x = 0
c = ["a", "b", "c"]
C = ["A", "B", "C"]
while True:
  if len(a[x]) == 0:
    print(C[x])
    break
  t = a[x].pop()
  for i in range(3):
    if t == c[i]:
      x = i
      break
Buggy code:
Sa = input()
Sb = input()
Sc = input()
l = [len(Sa), len(Sb), len(Sc)]
s = [Sa, Sb, Sc]
p = 0
while True:
    if l[p] <= 0:
        print("ABC"[p])
        break
    else:
        l[p] -= 1
        p = "abc".find(s[p][l[p] - len(s[p])])
        print(p)

Fixed code:
Sa = input()
Sb = input()
Sc = input()
l = [len(Sa), len(Sb), len(Sc)]
s = [Sa, Sb, Sc]
p = 0
while True:
    if l[p] <= 0:
        print("ABC"[p])
        break
    else:
        l[p] -= 1
        p = "abc".find(s[p][len(s[p])-l[p]-1])
Buggy code:
a=list(input())
b=list(input())
c=list(input())
oner='a'
while True:
        if oner=='a':
            if len(a)==0:break
            oner=a.pop(0)
        if oner=='b':
            if len(c)==0:break
            oner=b.pop(0)
        if oner=='c':
            if len(c)==0:break
            oner=c.pop(0)
        print(a,b,c)
print(oner.upper)

Fixed code:
a=list(input())
b=list(input())
c=list(input())
oner='a'
while True:
        if oner=='a':
            if len(a)==0:break
            oner=a.pop(0)
        if oner=='b':
            if len(b)==0:break
            oner=b.pop(0)
        if oner=='c':
            if len(c)==0:break
            oner=c.pop(0)
print(oner.upper())
Buggy code:
S = [input() for i in range(3)]
W = "ABC"
i = 0
while True:
    c = S[i][0]
    S[i] = S[i][1:]
    if len(S[i]) == 0:
        print(W[i])
        break
    i = ord(c) - ord('a')

Fixed code:
S = [input() for i in range(3)]
W = "ABC"
i = 0
while True:
    if len(S[i]) == 0:
        print(W[i])
        break
    c = S[i][0]
    S[i] = S[i][1:]
    i = ord(c) - ord('a')
Buggy code:
S_a = input()
S_b = input()
S_c = input()
a = []
b = []
c = []
for i in range(len(S_a)):
    a.append(S_a[i])
for j in range(len(S_b)):
    b.append(S_b[i])
for k in range(len(S_c)):
    c.append(S_c[i])
l = a
winner = 'A'
wlile len(l) > 0:
    x = l.pop(0)
    if x == 'a':
        l = a
        winner = 'A'
    elif x == 'b':
        l = b
        winner = 'B'
    else:
        l = c
        winner = 'C'
print(winner)

Fixed code:
S_a = input()
S_b = input()
S_c = input()
a = []
b = []
c = []
for i in range(len(S_a)):
    a.append(S_a[i])
for j in range(len(S_b)):
    b.append(S_b[j])
for k in range(len(S_c)):
    c.append(S_c[k])
l = a
winner = 'A'
while len(l) > 0:
    x = l.pop(0)
    if x == 'a':
        l = a
        winner = 'A'
    elif x == 'b':
        l = b
        winner = 'B'
    else:
        l = c
        winner = 'C'
print(winner)
Buggy code:
# cards = [input() for _ in range(3)]
dict = {'a':0, 'b':1, 'c':2}
inv = ['A', 'B', 'C']
turn = 'a'
game = True
while game:
    turn = cards[dict[turn]][0]
    cards[dict[turn]] = cards[dict[turn]][1:]
    for i in range(3):
        if cards[i] == '':
            print(inv[i])
            game = False

Fixed code:
cards = [input() for _ in range(3)]
dict = {'a':0, 'b':1, 'c':2}
inv = ['A', 'B', 'C']
turn = 'a'
game = True
while game:
    if cards[dict[turn]] == '':
        print(inv[dict[turn]])
        game = False
    else:
        next_turn = cards[dict[turn]][0]
        cards[dict[turn]] = cards[dict[turn]][1:]
        turn = next_turn
    # print(turn, cards)
Buggy code:
s={}
for i in range(3):
    s[chr(97+i)]=input()
turn="a"
while True:
    if not s[turn]:
        break
    else:
        turn=s[turn[0]]
        s[turn]=s[turn][1:]
print(turn.upper())


Fixed code:
s={}
for i in range(3):
    s[chr(97+i)]=input()
turn="a"
while True:
    if not s[turn]:
        break
    else:
        t=s[turn][0]
        s[turn]=s[turn][1:]
        turn=t
print(turn.upper())
Buggy code:
a=list(input())
b=list(input())
c=list(input())
#print(a,b,c)

card=a.pop(0)
#print(card)

flag=0
for i in range(len(a)+len(b)+len(c)):
    if card=='a' and len(a)==0 and flag==0:
        ans='A'
        flag=1
    elif card=='b' and len(b)==0 and flag==0:
        ans='B'
        flag=1
    elif card=='c' and len(c)==0 and flag==0:
        ans='C'
        flag=1
    else:
        if card=='a':
            card=a.pop(0)
        elif card=='b':
            card=b.pop(0)
        elif card=='c':
            card=c.pop(0)
    
print(ans)

Fixed code:
a=list(input())
b=list(input())
c=list(input())
#print(a,b,c)


card=a.pop(0)
#print(card)
flag=0
for i in range(301):
    if card=='a' and len(a)==0 and flag==0:
        ans='A'
        flag=1
    elif card=='b' and len(b)==0 and flag==0:
        ans='B'
        flag=1
    elif card=='c' and len(c)==0 and flag==0:
        ans='C'
        flag=1
    elif flag==0:
        if card=='a':
            card=a.pop(0)
        elif card=='b':
            card=b.pop(0)
        elif card=='c':
            card=c.pop(0)
    
print(ans)
Buggy code:
S = {}
S['A'] = input()
S['B'] = input()
S['C'] = input()

turn = 'A'
while True:
    if S[turn] == '':
        print(turn)
        break
    turn, S[turn] = S[turn][0].upper(), S[turn][1:]


Fixed code:
S = {}
S['A'] = input()
S['B'] = input()
S['C'] = input()

turn = 'A'
while True:
    if S[turn] == '':
        print(turn)
        break
    t = S[turn][0].upper()
    S[turn] = S[turn][1:]
    turn = t
Buggy code:
A = raw_input()
B = raw_input()
C = raw_input()

cnt = {'a': 0, 'b': 0, 'c': 0}
S = {'a': A, 'b': B, 'c': C}
turn = 'a'

while True:
	if cnt[turn] >= len(S[turn]):
		break	
	pop = S[turn][cnt[turn]]
	cnt[turn] += 1	
	turn = pop

print(turn.upper())



Fixed code:
A = input()
B = input()
C = input()

cnt = {'a': 0, 'b': 0, 'c': 0}
S = {'a': A, 'b': B, 'c': C}
turn = 'a'

while True:
	if cnt[turn] >= len(S[turn]):
		break	
	pop = S[turn][cnt[turn]]
	cnt[turn] += 1	
	turn = pop

print(turn.upper())
Buggy code:
S_a, S_b, S_c = map(list, [input() for _ in range(3)])
turn = 'a'
relation = {'a': S_a, 'b': S_b, 'c': S_c}
while True:
  card = relation[turn].pop(0)
  turn = card
  
  if len(S_a) == 0:
    print('A')
    exit()
  if len(S_b) == 0:
    print('B')
    exit()
  if len(S_c) == 0:
    print('C')
    exit()

Fixed code:
S_a, S_b, S_c = map(list, [input() for _ in range(3)])
turn = 'a'
relation = {'a': S_a, 'b': S_b, 'c': S_c}
while True: 
  if turn == 'a' and len(S_a) == 0:
    print('A')
    exit()
  if turn == 'b' and len(S_b) == 0:
    print('B')
    exit()
  if turn == 'c' and len(S_c) == 0:
    print('C')
    exit()
  
  card = relation[turn].pop(0)
  turn = card
Buggy code:
d={}
d[a]=list(input())
d[b]=list(input())
d[c]=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(upper(now))
    exit()

Fixed code:
d={}
d['a']=list(input())
d['b']=list(input())
d['c']=list(input())
now='a'
while True:
  if len(d[now])>0:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()
Buggy code:
S = {i:list(input()) for i in "abc"}
while S[s]: s=S[s].pop(0)
print(s.upper())

Fixed code:
S = {i:list(input()) for i in "abc"}
s = "a"
while S[s]: s=S[s].pop(0)
print(s.upper())
Buggy code:
sA = input().rstrip()
sB = input().rstrip()
sC = input().rstrip()
next = 'a'
while True:
    #print(next,sA,sB,sC)
    if next == 'a' and len(sA) == 0:
        print("A")
        break
    elif next == 'b' and len(sB) == 0:
        print("B")
        break
    elif next == 'c' and len(sC) == 0:
        print("C")
        break

    if next == 'a':
        next = sA[0]
        sA = sA[1:]
    elif next == 'b':
        next = sB[0]
        sB = sB[1:]
    elif next == 'c':
        next = sB[0]
        sC = sC[1:]

Fixed code:
sA = input().rstrip()
sB = input().rstrip()
sC = input().rstrip()
next = 'a'
while True:
    #print(next,sA,sB,sC)
    if next == 'a' and len(sA) == 0:
        print("A")
        break
    elif next == 'b' and len(sB) == 0:
        print("B")
        break
    elif next == 'c' and len(sC) == 0:
        print("C")
        break

    if next == 'a':
        next = sA[0]
        sA = sA[1:]
    elif next == 'b':
        next = sB[0]
        sB = sB[1:]
    elif next == 'c':
        next = sC[0]
        sC = sC[1:]
Buggy code:
Sa = input()
Sb = input()
Sc = input()
pl = 0
while(True):
  if pl == 0:
    s = Sa[0]
    if s == "a":
      pl = 0
    elif s == "b":
      pl = 1
    else:
      pl = 2
    Sa = Sa[1:]
  elif pl == 1:
    s = Sb[0]
    if s == "a":
      pl = 0
    elif s == "b":
      pl = 1
    else:
      pl = 2
    Sb = Sb[1:]
  else:
    s = Sc[0]
    if s == "a":
      pl = 0
    elif s == "b":
      pl = 1
    else:
      pl = 2
    Sc = Sc[1:]
  if len(Sa)==0:
    print("A")
    break
  elif len(Sb)==0:
    print("B")
    break
  elif len(Sc)==0:
    print("C")
    break

Fixed code:
Sa = input()
Sb = input()
Sc = input()
pl = 0
while(True):
  if len(Sa)==0 and pl==0:
    print("A")
    break
  elif len(Sb)==0 and pl==1:
    print("B")
    break
  elif len(Sc)==0 and pl==2:
    print("C")
    break
  if pl == 0:
    s = Sa[0]
    if s == "a":
      pl = 0
    elif s == "b":
      pl = 1
    else:
      pl = 2
    Sa = Sa[1:]
  elif pl == 1:
    s = Sb[0]
    if s == "a":
      pl = 0
    elif s == "b":
      pl = 1
    else:
      pl = 2
    Sb = Sb[1:]
  else:
    s = Sc[0]
    if s == "a":
      pl = 0
    elif s == "b":
      pl = 1
    else:
      pl = 2
    Sc = Sc[1:]
Buggy code:
a,b,c=(list(input()) for x in range(3))
n=a.pop(0)
while not len(a)==0 or len(b)==0 or len(c)==0:
   if n=='a':
      n=a.pop(0)
   elif n=='b':
      n=b.pop(0)
   else:
      n=c.pop(0)
if a=='':print('A')
elif b=='':print('B')
else:print('C')

Fixed code:
a,b,c=(list(input()) for x in range(3))
n=a.pop(0)
while not ((len(a)==0 and n=='a') or (len(b)==0 and n=='b') or (len(c)==0 and n=='c')):
   if n=='a':n=a.pop(0)
   elif n=='b':n=b.pop(0)
   else:n=c.pop(0)
if n=='a':print('A')
elif n=='b':print('B')
else:print('C')
Buggy code:
sa = str(input())
sb = str(input())
sc = str(input())
turn = 'a'
while True:
    if turn == 'a':
        if sa == '':
            print('A')
            exit()
        turn = sa[0]
        sa = sa[1:]
    elif turn == 'b':
        if sb == '':
            print('B')
            exit()
        turn = sb[0]
        sb = sb[1:]
    else:
        if sc == '':
            print('C')
            exit()
        turn = sc[0]
        sc = sc[1:]
    print(turn)


Fixed code:
sa = str(input())
sb = str(input())
sc = str(input())
turn = 'a'
while True:
    if turn == 'a':
        if sa == '':
            print('A')
            exit()
        turn = sa[0]
        sa = sa[1:]
    elif turn == 'b':
        if sb == '':
            print('B')
            exit()
        turn = sb[0]
        sb = sb[1:]
    else:
        if sc == '':
            print('C')
            exit()
        turn = sc[0]
        sc = sc[1:]
Buggy code:
A=input()
B=input()
C=input()
t=[0,0,0]
flag="a"
while True:
  if flag=="a":
    if len(A)==t[0]+1:
      print("A")
      break
    else:
      flag=A[t[0]]
      t[0]+=1
  elif flag=="b":
    if len(B)==t[1]+1:
      print("B")
      break
    else:
      flag=B[t[1]]
      t[1]+=1
  elif flag=="c":
    if len(C)==0:
      print("C")
      break
    else:
      flag=C[t[2]]
      t[2]+=1


Fixed code:
A=input()
B=input()
C=input()
t=[0,0,0]
flag="a"
while True:
  if flag=="a":
    if len(A)==t[0]:
      print("A")
      break
    else:
      flag=A[t[0]]
      t[0]+=1
  elif flag=="b":
    if len(B)==t[1]:
      print("B")
      break
    else:
      flag=B[t[1]]
      t[1]+=1
  elif flag=="c":
    if len(C)==t[2]:
      print("C")
      break
    else:
      flag=C[t[2]]
      t[2]+=1
Buggy code:
sa = list(map(str, input()))
sb = list(map(str, input()))
sc = list(map(str, input()))

turn = 0

while True:
    s = ""
    if turn == 0:
        if len(sa) != 0:
            s = sa.pop(0)
        else:
            print("A")
            exit()
    elif turn == 1:
        if len(sb) != 0:
            s = sb.pop(0)
        else:
            print("B")
            exit()
    else:
        if len(sc) != 0:
            s = sc.pop(0)
        else:
            print("C")
            exit()

    if s == "a":
        turn = 0
    elif s == "b":
        turn = 1
    else:
        turn = 2

    print(sa, sb, sc)

Fixed code:
sa = list(map(str, input()))
sb = list(map(str, input()))
sc = list(map(str, input()))

turn = 0

while True:
    s = ""
    if turn == 0:
        if len(sa) != 0:
            s = sa.pop(0)
        else:
            print("A")
            exit()
    elif turn == 1:
        if len(sb) != 0:
            s = sb.pop(0)
        else:
            print("B")
            exit()
    else:
        if len(sc) != 0:
            s = sc.pop(0)
        else:
            print("C")
            exit()

    if s == "a":
        turn = 0
    elif s == "b":
        turn = 1
    else:
        turn = 2
Buggy code:
sa = input()
sb = input()
sc = input()

def func(x) :
    global sa, sb, sc
    if x == "a" :
        if sa :
            k = sa[0]
            sa = sa[1:]
            return func(k)
        else :
            return "A"
    elif x == "b" :
        if sb :
            k = sb[0]
            sb = sb[1:]
            return func(k)
        else :
            return "B"
    else :
        if sc :
            k = sc[0]
            sc = sc[1:]
            return func(k)
        else :
            return "C"

print(func("A"))

Fixed code:
sa = input()
sb = input()
sc = input()

def func(x) :
    global sa, sb, sc
    if x == "a" :
        if sa :
            k = sa[0]
            sa = sa[1:]
            return func(k)
        else :
            return "A"
    elif x == "b" :
        if sb :
            k = sb[0]
            sb = sb[1:]
            return func(k)
        else :
            return "B"
    else :
        if sc :
            k = sc[0]
            sc = sc[1:]
            return func(k)
        else :
            return "C"

print(func("a"))
Buggy code:
first = input()
second = input()
third = input()

d = {}
d["a"]=first
d["b"]=second
d["c"]=third


flag = False
run = "a"
while flag != True:
 
  if d[run] == "":
    flag = True
    print(run)
  else:
    l = len(d[run])
    temp = d[run][0]
    
    d[run] = d[run][1:l]
    
    run = temp

Fixed code:
first = input()
second = input()
third = input()

d = {}
d["a"]=first
d["b"]=second
d["c"]=third


flag = False
run = "a"
while flag != True:
 
  if d[run] == "":
    flag = True
    print(run.upper())
  else:
    l = len(d[run])
    temp = d[run][0]
    
    d[run] = d[run][1:l]
    
    run = temp
Buggy code:
A =list(str(input()))
B =list(str(input()))
C =list(str(input()))
P=A
for i in range(len(A)+len(B)+len(C)+3):
    print(P)
    if P[0] == 'a':
        
        P.pop(0)
        P=A
        if len(A) ==0:
            print('A')
            exit()
    elif P[0] =='b':

        P.pop(0)
        P=B
        if len(B) ==0:
            print('B')
            exit()
    elif P[0] =='c':

        P.pop(0)
        P=C
        if len(C) ==0:
            print('C')
            exit()

Fixed code:
A =list(str(input()))
B =list(str(input()))
C =list(str(input()))
P=A
for i in range(len(A)+len(B)+len(C)+3):
    if P[0] == 'a':
        
        P.pop(0)
        P=A
        if len(A) ==0:
            print('A')
            exit()
    elif P[0] =='b':

        P.pop(0)
        P=B
        if len(B) ==0:
            print('B')
            exit()
    elif P[0] =='c':

        P.pop(0)
        P=C
        if len(C) ==0:
            print('C')
            exit()
Buggy code:
ma=input()
mb=input()
mc=input()
mdic={"a":ma,"b":mb,"c":mc}
m="a"
i=0
ndic={"a":0,"b":0,"c":0}
while ndic[m]=<len(mdic[m]):
  m=mdic[m][ndic[m]]
  ndic[m]+=1
print(m.upper())

Fixed code:
ma=input()
mb=input()
mc=input()
mdic={"a":ma,"b":mb,"c":mc}
m="a"
ndic={"a":0,"b":-1,"c":-1}
while ndic[m]<len(mdic[m]):
  m=mdic[m][ndic[m]]
  ndic[m]+=1
print(m.upper())
Buggy code:
A_cards = list(input())
B_cards = list(input())
C_cards = list(input())
who = "a"
while(True):
    if(who == "a"):
        if(len(A_cards)==0):
            print("A")
            exit()
        else:
            who = A_cards[0]
            del A_cards[0]
    elif(who == "b"):
        if(len(B_cards)==0):
            print("B")
            exit()
        else:
            who = B_cards[0]
            del B_cards[0]
    else:
        if(len(C_cards)==0):
            print("C")
            exit()


Fixed code:
A_cards = list(input())
B_cards = list(input())
C_cards = list(input())
who = "a"
while(True):
    if(who == "a"):
        if(len(A_cards)==0):
            print("A")
            exit()
        else:
            who = A_cards[0]
            del A_cards[0]
    if(who == "b"):
        if(len(B_cards)==0):
            print("B")
            exit()
        else:
            who = B_cards[0]
            del B_cards[0]
    if(who == "c"):    
        if(len(C_cards)==0):
            print("C")
            exit()
        else:
            who = C_cards[0]
            del C_cards[0]
Buggy code:
s={"a":input(),"b":input(),"c":input()}
i= "a"
while(len(s[i]) != 0):
        j = s[i][0]
        j = i
        s[i] = s[i][1:]
print(i.upper())

Fixed code:
s={'a':input(),'b':input(),'c':input()}
n='a'
while len(s[n])!=0:
    j=s[n][0]
    s[n]=s[n][1:]
    n=j
print(j.upper())
Buggy code:
A = input()
B = input()
C = input()

a = list(A)
b = list(B)
c = list(C)
state = [a, b, c]

player = 0
player_name = ["a", "b", "c"]
get_player = {"a": 0, "b":1, "c": 2}
while True:
    if len(state[player]) == 0:
        print(player_name[player])
        exit()
    next_player_name = state[player].pop(0)
    player = get_player[next_player_name]


Fixed code:
A = input()
B = input()
C = input()
state = [list(A), list(B), list(C)]

player = 0
player_name = ["A", "B", "C"]
get_player = {"a": 0, "b":1, "c": 2}
while True:
    if len(state[player]) == 0:
        print(player_name[player])
        exit()
    next_player_name = state[player].pop(0)
    player = get_player[next_player_name]
Buggy code:
sa = input()
sb = input()
sc = input()
"""
sa = 'aca'
sb = 'accc'
sc = 'ca'   #A
sa = 'abcb'
sb = 'aacb'
sc = 'bccc' #C
"""
now = 'a'
ca = 0
cb = 0
cc = 0

RC = ''
while RC == '':
    if now == 'a':
        print('a')
        if ca == len(sa):
            break
        now = sa[ca]
        ca += 1

    elif now == 'b':
        print('b')
        if cb == len(sb):
            break
        now = sb[cb]
        cb += 1

    else:
        print('c')
        if cc == len(sc):
            break
        now = sc[cc]
        cc += 1

print(now.upper())


Fixed code:
sa = input()
sb = input()
sc = input()
"""
sa = 'aca'
sb = 'accc'
sc = 'ca'   #A
sa = 'abcb'
sb = 'aacb'
sc = 'bccc' #C
"""
now = 'a'
ca = 0
cb = 0
cc = 0

RC = ''
while RC == '':
    if now == 'a':
        if ca == len(sa):
            break
        now = sa[ca]
        ca += 1

    elif now == 'b':
        if cb == len(sb):
            break
        now = sb[cb]
        cb += 1

    else:
        if cc == len(sc):
            break
        now = sc[cc]
        cc += 1

print(now.upper())
Buggy code:
A=list(input())
B=list(input())
C=list(input())
D={"a":A, "b":B, "c":C}
X=A
while True:
    X=X.pop(0)
    X=D[X[0]] 
    if len(X)==0:
        print("A" if X==A else "B" if X==B else "C")   
        break 
    

Fixed code:
A=list(input())
B=list(input())
C=list(input())
D={"a":A, "b":B, "c":C}
X=A
while True:
    d=X[0]
    X.pop(0)
    X=D[d] 
    if len(X)==0:
        print(d.upper())   
        break
Buggy code:
A = str(input())
B = str(input())
C = str(input())
X=A
while True:
    if X == "a":
        X = A[0]
        A.pop(0)
        if len(A) == 0:
            print("A")
            break
    elif X == b:
        X = B[0]
        B.pop(0)
        if len(B) == 0:
            print("B")
            break
    else:
        X = C[0]
        C.pop(0)
        if len(C) == 0:
            print("C")
            break

Fixed code:
A = list(str(input()))
B = list(str(input()))
C = list(str(input()))
X="a"
while True:
    if X == "a":
        if len(A) == 0:
            print("A")
            break
        X = A[0]
        A.pop(0)
    elif X == "b":
        if len(B) == 0:
            print("B")
            break
        X = B[0]
        B.pop(0)
    else:
        if len(C) == 0:
            print("C")
            break
        X = C[0]
        C.pop(0)
Buggy code:
s=[input() for i in range(3)]
l=[len(s[i]) for i in range(3)]
abc=[0,0,0]
now=0
print(s)
print(l)
while abc[now]!=l[now]:
    s_sub=s[now][abc[now]]
    abc[now]+=1
    now=(0 if s_sub=="a" else 1 if s_sub=="b" else 2)
    
print("A" if now==0 else "B" if now==1 else "C")

Fixed code:
s=[input() for i in range(3)]
l=[len(s[i]) for i in range(3)]
abc=[0,0,0]
now=0

while abc[now]!=l[now]:
    s_sub=s[now][abc[now]]
    abc[now]+=1
    now=(0 if s_sub=="a" else 1 if s_sub=="b" else 2)
    
print("A" if now==0 else "B" if now==1 else "C")
Buggy code:
stri = [input() for _ in range(3)]
str_now = [0 for _ in range(3)]
now = 0
while True:
  if str_now[now] == len(stri[now]):
    print(chr(ord('A')+now))
    exit()
  else:
    str_now[now] += 1
    now = ord(stri[now][str_now[now-1]]) - ord('a')


Fixed code:
stri = [input() for _ in range(3)]
str_now = [0 for _ in range(3)]
now = 0
while True:
  if str_now[now] == len(stri[now]):
    print(chr(ord('A')+now))
    exit()
  else:
    str_now[now] += 1
    now = ord(stri[now][str_now[now]-1]) - ord('a')
Buggy code:
def Turn(sa, sb, sc, name):
    if name == 'a':
        card = sa.pop()
    elif name == 'b':
        card = Sb.pop()
    else:
        card = sc.pop()

    return card


def TurnLen(sa, sb, sc, name):
    if name == 'a':
        num = len(sa)
    elif name == 'b':
        num = len(sb)
    else:
        num = len(sc)

    return num


Sa = list(input())
Sb = list(input())
Sc = list(input())
Sa.reverse()
Sb.reverse()
Sc.reverse()

TName = "a"
TName = Turn(Sa, Sb, Sc, TName)

while TurnLen(Sa, Sb, Sc, TName) != 0:
    Tname = Turn(Sa, Sb, Sc, TName)

print(Tname.upper())



Fixed code:
def Turn(sa, sb, sc, name):
    if name == 'a':
        card = sa.pop()
    elif name == 'b':
        card = Sb.pop()
    else:
        card = sc.pop()

    return card


def TurnLen(sa, sb, sc, name):
    if name == 'a':
        num = len(sa)
    elif name == 'b':
        num = len(sb)
    else:
        num = len(sc)

    return num


Sa = list(input())
Sb = list(input())
Sc = list(input())
Sa.reverse()
Sb.reverse()
Sc.reverse()

TName = "a"
TName = Turn(Sa, Sb, Sc, TName)

while TurnLen(Sa, Sb, Sc, TName) != 0:
    TName = Turn(Sa, Sb, Sc, TName)

print(TName.upper())