qyliang/CodeNanoFix huggingface dataset:
Buggy code:
s={i:list(input())for i in'abc'}
i='a'
while d[i]:i=s[i].pop(0)
print(i.upper())

Fixed code:
s={i:list(input())for i in'abc'}
i='a'
while s[i]:i=s[i].pop(0)
print(i.upper())
Buggy code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = {'a':list(ns())[::-1],'b':list(ns())[::-1],'c':list(ns())[::-1]}
i = 'a'
while s[i]:
    s[i].pop()

print(i.upper())

Fixed code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = {'a':list(ns())[::-1],'b':list(ns())[::-1],'c':list(ns())[::-1]}
i = 'a'
while s[i]:
    i = s[i].pop()

print(i.upper())
Buggy code:
a=list(input())
b=list(input())
c=list(input())
order='a'
while True:
  if order='a':
    order=a[0]
    if len(a)==1:
      print('A')
      break
    else:
      a=a[1:]
  elif order='b':
    order=b[0]
    if len(b)==1:
      print('B')
      break
    else:
      b=b[1:]
  elif order='c':
    order=c[0]
    if len(c)==1:
      print('C')
      break
    else:
      c=c[1:]

Fixed code:
a=list(input())
b=list(input())
c=list(input())
order='a'
while True:
  if order=='a':
    if len(a)==0:
      print('A')
      break
    else:
      order=a[0]
      a=a[1:]
  elif order=='b':
    if len(b)==0:
      print('B')
      break
    else:
      order=b[0]
      b=b[1:]
  elif order=='c':
    if len(c)==0:
      print('C')
      break
    else:
      order=c[0]
      c=c[1:]
Buggy code:
SA, SB, SC = [input() for i in range(3)]
SA = SA + '0'
SB = SB + '0'
SC = SC + '0'

card = SA[0]
SA = SA[1:]

for i in range(1):
    if SA == '0' and card == 'a':
        print('A')
        break
    elif SB == '0' and card == 'b':
        print('B')
        break
    elif SC == '0' and card == 'c':
        print('C')
        break
    
    if card == 'a':
        card = SA[0]
        SA = SA[1:]
    elif card == 'b':
        card = SB[0]
        SB = SB[1:]
    elif card == 'c':
        card = SC[0]
        SC = SC[1:]

Fixed code:
SA, SB, SC = [input() for i in range(3)]
SA = SA + '0'
SB = SB + '0'
SC = SC + '0'

card = SA[0]
SA = SA[1:]

for i in range(303):
    if SA == '0' and card == 'a':
        print('A')
        break
    elif SB == '0' and card == 'b':
        print('B')
        break
    elif SC == '0' and card == 'c':
        print('C')
        break
    
    if card == 'a':
        card = SA[0]
        SA = SA[1:]
    elif card == 'b':
        card = SB[0]
        SB = SB[1:]
    elif card == 'c':
        card = SC[0]
        SC = SC[1:]
Buggy code:
S = [str(input()) for x in range(3)]
print(S)
turn = 0
nextturn = 0
while True:
  nextturn = 'abc'.find(S[turn][0])
  S[turn] = S[turn][1:]
  turn = nextturn
  if S[turn] == '':
    print('ABC'[turn])
    break

Fixed code:
S = [str(input()) for x in range(3)]
turn = 0
nextturn = 0
while True:
  nextturn = 'abc'.find(S[turn][0])
  S[turn] = S[turn][1:]
  turn = nextturn
  if S[turn] == '':
    print('ABC'[turn])
    break
Buggy code:
d = { 'a':input(), 'b':input(), 'c':input() }
pointer = 'a'
while True:
    if 0 < len(d[pointer]):
        tmp = d[pointer][0]
        d[pointer] = s[pointer][1:]
        pointer = tmp
    else:
        print(pointer.upper())
        break

Fixed code:
d = { 'a':input(), 'b':input(), 'c':input() }
pointer = 'a'
while True:
    if 0 < len(d[pointer]):
        tmp = d[pointer][0]
        d[pointer] = d[pointer][1:]
        pointer = tmp
    else:
        print(pointer.upper())
        break
Buggy code:
A, B, C = (input() for i in range(3))
cnt_a = 0; cnt_b = -1; cnt_c = -1
current_card = A[cnt_a]
while True:
    print(current_card)
    if current_card == "a":
        cnt_a += 1
        if cnt_a == len(A):
            print("A")
            exit()
        else:
            current_card = A[cnt_a]
    elif current_card == "b":
        cnt_b += 1
        if cnt_b == len(B):
            print("B")
            exit()
        else:
            current_card = B[cnt_b]
    elif current_card == "c":
        cnt_c += 1
        if cnt_c == len(C):
            print("C")
            exit()
        else:
            current_card = C[cnt_c]


Fixed code:
A, B, C = (input() for i in range(3))
cnt_a = 0; cnt_b = -1; cnt_c = -1
current_card = A[cnt_a]
while True:
    if current_card == "a":
        cnt_a += 1
        if cnt_a == len(A):
            print("A")
            exit()
        else:
            current_card = A[cnt_a]
    elif current_card == "b":
        cnt_b += 1
        if cnt_b == len(B):
            print("B")
            exit()
        else:
            current_card = B[cnt_b]
    elif current_card == "c":
        cnt_c += 1
        if cnt_c == len(C):
            print("C")
            exit()
        else:
            current_card = C[cnt_c]
Buggy code:
s = {c:list(input()) for c in "abc"}
s = "a"
while S[s]:s = S[s].pop(0)
print(s.upper())

Fixed code:
S = {c:list(input()) for c in "abc"}
s = "a"
while S[s]:s = S[s].pop(0)
print(s.upper())
Buggy code:
S = [list( input()) for _ in range(3)]
C = ['A', 'B', 'C']
now = 0
nowc = 'A'
while True:
    if not S[i]:
        ans = C[i]
        break
    nowc = S[i].pop(0)
    if nowc == 'a':
        now = 0
    elif nowc == 'b':
        now = 1
    else:
        now = 2
print(ans)

Fixed code:
S = [list( input()) for _ in range(3)]
C = ['A', 'B', 'C']
now = 0
nowc = 'A'
while True:
    if not S[now]:
        ans = C[now]
        break
    nowc = S[now].pop(0)
    if nowc == 'a':
        now = 0
    elif nowc == 'b':
        now = 1
    else:
        now = 2
print(ans)
Buggy code:
a,b,c = [str(input()) for i in range(3)]
current = 'a'
while True:
    cur = current[len(current)-1]
    if cur == 'a':
      current+=a[0]
      a=a[1:]
    elif cur == 'b':
      current+=b[0]
      b=b[1:]
    elif cur == 'c':
      current+=c[0]
      c=c[1:]
    if a == '' or b =='' or c =='':
      print(current[len(current)-1].upper())
      print(current)
      break

Fixed code:
a,b,c = [str(input()) for i in range(3)]
current = 'a'
while True:
  try:
    cur = current[len(current)-1]
    if cur == 'a':
      current+=a[0]
      a=a[1:]
    elif cur == 'b':
      current+=b[0]
      b=b[1:]
    elif cur == 'c':
      current+=c[0]
      c=c[1:]
  except:
      print(current[len(current)-1].upper())
      break
Buggy code:
S = dict()
S['a'] = list(input())[::-1]
S['b'] = list(input())[::-1]
S['c'] = list(input())[::-1]
 p = 'a'
while S[]:
  p = S[p].pop()  
print(player.upper())

Fixed code:
S = dict()
S['a'] = list(input())[::-1]
S['b'] = list(input())[::-1]
S['c'] = list(input())[::-1]
p = 'a'
while S[p]:
  p = S[p].pop()  
print(p.upper())
Buggy code:
Sa = input()
Sb = input()
Sc = input()

dic = {'a':Sa, 'b':Sb, 'c':Sc}

doCont = True
person = 'a'
result = ''
while doCont:
  drop_card = dic[person][0]
  dic[person] = dic[person][1:]

  if (len(dic[person]) == 0):
    doCont = False
    result = person.upper()
  person = drop_card

print(result)

Fixed code:
Sa = input()
Sb = input()
Sc = input()

dic = {'a':Sa, 'b':Sb, 'c':Sc}

doCont = True
person = 'a'
result = ''
while doCont:
  if (len(dic[person]) == 0):
    doCont = False
    result = person.upper()
    break

  drop_card = dic[person][0]
  dic[person] = dic[person][1:]
  person = drop_card

print(result)
Buggy code:
cards = dict((x, list(input())) for x in 'abc')

turn = 'a'
while len(cards[turn]):
  turn = cards[turn].pop(0)
  print(turn.upper())


Fixed code:
cards = dict((x, list(input())) for x in 'abc')

turn = 'a'
while len(cards[turn]):
  turn = cards[turn].pop(0)
print(turn.upper())
Buggy code:
A=input())
B=input())
C=input())

card={a:A,b:B,c:C}
answer=["a":"A","b":"B","c":"C"]
turn="a"

while True:
    if len(card[turn])==0:
        break
    next_turn=card[turn][0]
    card[turn]=card[turn][1:]
    turn=next_turn

print(answer[turn])

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

card={"a":A,"b":B,"c":C}
answer={"a":"A","b":"B","c":"C"}
turn="a"

while True:
    if len(card[turn])==0:
        break
    next_turn=card[turn][0]
    card[turn]=card[turn][1:]
    turn=next_turn

print(answer[turn])
Buggy code:
s = open(0).read().split()
x = s[0][0]
s[0] = s[0][1:]

while True:
  p = ord(x)-97
  if len(s[p] == 0):
    print ord(x).upper()
    break
  x = s[p][0]
  s[p] = s[p][1:]


Fixed code:
s = open(0).read().split()
x = s[0][0]
s[0] = s[0][1:]
 
while True:
  p = ord(x)-97
  if len(s[p]) == 0:
    print(x.upper())
    break
  x = s[p][0]
  s[p] = s[p][1:]
Buggy code:
s = dict()
s["a"] = list(input())[::-1]
s["b"] = list(input())[::-1]
s["c"] = list(input())[::-1]

index = s.pop()

while s[index]:
    index = s.pop()

print(index.upper())

Fixed code:
s = dict()
s["a"] = list(input())[::-1]
s["b"] = list(input())[::-1]
s["c"] = list(input())[::-1]

index = s["a"].pop()

while s[index]:
    index = s[index].pop()

print(index.upper())
Buggy code:
def nextTurn(a):
  if a == "a":
    return 0
  elif a == "b":
    return 1
  else:
    return 2
    
hand = [list(input()) for i in range(3)]
turn = nextTurn(hand[0].pop(0))
while(True):
  tmp = turn
  turn = nextTurn(hand[turn].pop(0))
  if len(hand[tmp]) == 0:
    if tmp == 0:
      print("A")
    elif tmp == 1:
      print("B")
    else:
      print("C")
    break
  

Fixed code:
def nextTurn(a):
  if a == "a":
    return 0
  elif a == "b":
    return 1
  else:
    return 2
    
hand = [list(input()) for i in range(3)]
turn = nextTurn(hand[0].pop(0))
while(True):
  if len(hand[turn]) == 0:
    if turn == 0:
      print("A")
    elif turn == 1:
      print("B")
    else:
      print("C")
    break
  turn = nextTurn(hand[turn].pop(0))
Buggy code:
SA = list(input())
SB = list(input())
SC = list(input())

x = "a"

while True:
  if x == "a":
    if len(SA) ==0:
      print("A")
      exit()

    x = SA[0]
    SA.remove(x)
  
  elif x == "b":
    if len(SB) ==0:
      print("B")
      exit()

    x = SB[0]
    SB.remove(x)

  else:
    if len(SB) == 0:
      print("C")
      exit()
    
    x = SC[0]
    SC.remove(x)


Fixed code:
SA = list(input())
SB = list(input())
SC = list(input())

x = "a"

while True:
  if x == "a":
    if len(SA) ==0:
      print("A")
      exit()

    x = SA[0]
    SA.remove(x)
  
  elif x == "b":
    if len(SB) ==0:
      print("B")
      exit()

    x = SB[0]
    SB.remove(x)

  else:
    if len(SC) == 0:
      print("C")
      exit()
    
    x = SC[0]
    SC.remove(x)
Buggy code:
a = input()
b = input()
c = input()
Sa = [a[i] for i in range(a)]
Sb = [b[i] for i in range(b)]
Sc = [c[i] for i in range(c)]
turn = "a"
while True:
  if turn == "a":
    if len(Sa) == 0:
      print("A")
      break
    else:
      turn = Sa.pop(0)
  elif turn == "b":
    if len(Sb) == 0:
      print("B")
      break
    else:
      turn = Sb.pop(0)
  else:
    if len(Sc) == 0:
      print("C")
      break
    else:
      turn = Sc.pop(0)

Fixed code:
a = input()
b = input()
c = input()
Sa = [a[i] for i in range(len(a))]
Sb = [b[i] for i in range(len(b))]
Sc = [c[i] for i in range(len(c))]
turn = "a"
while True:
  if turn == "a":
    if len(Sa) == 0:
      print("A")
      break
    else:
      turn = Sa.pop(0)
  elif turn == "b":
    if len(Sb) == 0:
      print("B")
      break
    else:
      turn = Sb.pop(0)
  else:
    if len(Sc) == 0:
      print("C")
      break
    else:
      turn = Sc.pop(0)
Buggy code:
A, B, C = map(str, [input() for i in range(3)])
dic = {'A': A, 'B': B, 'C': C}
turn = 'A'
while True:
    print(dic['A'], dic['B'], dic['C'])
    if dic[turn] != '':
        turn_b = turn
        turn = dic[turn][0].upper()
        dic[turn_b] = dic[turn_b][1:]
    else:
        print(turn)
        break


Fixed code:
A, B, C = map(str, [input() for i in range(3)])
dic = {'A': A, 'B': B, 'C': C}
turn = 'A'
while True:
    if dic[turn] != '':
        turn_b = turn
        turn = dic[turn_b][0].upper()
        dic[turn_b] = dic[turn_b][1:]
    else:
        print(turn)
        break
Buggy code:
sa = input()
sb = input()
sc = input()

def judges(lis):
    if lis[0] == 'a':
        judge=1
    elif lis[0] == 'b':
        judge=2
    else:
        judge=3
    return judge
  
  import sys

judge = 1
while(1):
    if judge == 1:
        try:
            judge = judges(sa)
            sa = sa[1:]
            print(sa)
        except IndexError:
            print('A')
            break
    
    elif judge == 2:
        try:
            judge = judges(sb)
            sb = sb[1:]
            print(sb)
        except IndexError:
            print('B')
            break
    else:
        try:
            judge = judges(sc)
            sc = sc[1:]
            print(sc)
        except IndexError:
            print('C')
            break

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

def judges(lis):
    if lis[0] == 'a':
        judge=1
    elif lis[0] == 'b':
        judge=2
    else:
        judge=3
    return judge

import sys

judge = 1
while(1):
    if judge == 1:
        try:
            judge = judges(sa)
            sa = sa[1:]
        except IndexError:
            print('A')
            break
    
    elif judge == 2:
        try:
            judge = judges(sb)
            sb = sb[1:]
        except IndexError:
            print('B')
            break
    else:
        try:
            judge = judges(sc)
            sc = sc[1:]
        except IndexError:
            print('C')
            break
Buggy code:
dic_s = {x:input() for x in 'abc'}

dic_i = {x:i for x,i in zip('abc',[0,0,0])}
dic_max = {x:len(dic_s[x]) for x in 'abc'}
nt = 'a'
while True:
  dic_i[nt] += 1
  if dic_max[nt] == dic_i[nt]:
    break
  else:
    nt = dic_s[nt][dic_i[nt]]
print(nt)      

Fixed code:
dic_s = {x:input() for x in 'abc'}

dic_i = {x:i for x,i in zip('abc',[0,0,0])}
dic_max = {x:len(dic_s[x]) for x in 'abc'}
nt = 'a'
while True:  
  if dic_max[nt] == dic_i[nt]:
    break
  else:
    dic_i[nt] += 1
    nt = dic_s[nt][dic_i[nt]-1]    
print(nt.upper())
Buggy code:
ss = {i:list(input()) for i in "abc"}
x = ss[a].pop(0)
while True:
  if not ss[x]:
    print(x.upper())
    break
  else:
    x = ss[x][0]

Fixed code:
ss = {i:list(input()) for i in "abc"}
x = ss['a'].pop(0)
while True:
  if not ss[x]:
    print(x.upper())
    break
  else:
    x = ss[x].pop(0)
Buggy code:
aa = input()
bb = input()
cc = input()
def kansu(char,a,b,c):    
    if char == 'a':
        if not a:
            return 'a'
        else:
            char = a[0:1]
            a = a[1:]
            r = kansu(char,a,b,c)
    elif char == 'b':
        if not b:
            return 'b'
        else:
            char = b[0:1]
            b = b[1:]
            r = kansu(char,a,b,c)
    else:
        if not c:
            return 'c'
        else:
            char = c[0:1]
            c =c[1:]
            r = kansu(char,a,b,c)
    return r
            
charc = aa[0:1]
aa = aa[1:]
result = kansu(charc,aa,bb,cc)
print(result)

Fixed code:
aa = input()
bb = input()
cc = input()
def kansu(char,a,b,c):    
    if char == 'a':
        if not a:
            return 'A'
        else:
            char = a[0:1]
            a = a[1:]
            r = kansu(char,a,b,c)
    elif char == 'b':
        if not b:
            return 'B'
        else:
            char = b[0:1]
            b = b[1:]
            r = kansu(char,a,b,c)
    else:
        if not c:
            return 'C'
        else:
            char = c[0:1]
            c =c[1:]
            r = kansu(char,a,b,c)
    return r
            
charc = aa[0:1]
aa = aa[1:]
result = kansu(charc,aa,bb,cc)
print(result)
Buggy code:
S = {i:list(input()) for i in 'abc'}
s = 'a'
while S[s]:s == S[s].pop(0)
print(s.upper())

Fixed code:
S={key:list(input()) for key in "abc"}
s="a"
while S[s]:
    s=S[s].pop(0)
    
print(s.upper())
Buggy code:
Sa = list(input())
Sb = list(input())
Sc = list(input())
turn = Sa
ans ="A"
while turn != []:
  card =turn[0]
  turn.pop(0)
  if card =="a":
    turn ==Sa
    ans ="A"
  elif card =="b":
    turn ==Sb
    ans ="B"
  else:
    turn ==Sc
    ans ="C"
print(ans)

Fixed code:
Sa = list(input())
Sb = list(input())
Sc = list(input())
turn = Sa
ans ="A"
while turn != []:
  card =turn[0]
  turn.pop(0)
  if card =="a":
    turn =Sa
    ans ="A"
  elif card =="b":
    turn =Sb
    ans ="B"
  else:
    turn =Sc
    ans ="C"
print(ans)
Buggy code:
s_a = list(input())[::-1]
s_b = list(input())[::-1]
s_c = list(input())[::-1]

person = "a"

try:
  while True:
    print("s_a", s_a)
    print("s_a", s_b)
    print("s_a", s_c)
    print("---------")
    if person == "a":
      person = s_a.pop()
    elif person == "b":
      person = s_b.pop()
    else:
      person = s_c.pop()
except IndexError:
  print(person.upper())

Fixed code:
s_a = list(input())[::-1]
s_b = list(input())[::-1]
s_c = list(input())[::-1]

person = "a"

try:
  while True:
    if person == "a":
      person = s_a.pop()
    elif person == "b":
      person = s_b.pop()
    else:
      person = s_c.pop()
except IndexError:
  print(person.upper())
Buggy code:
a = input()
b = input()
c = input()
i = "a"
player = {"a":a,"b":b,"c":c}

while True:
    l = player[i][0]
    player[i] = player[i][1:]
    if len(player[i])==0:
        print(i)
        break
    i = l

Fixed code:
a = input()
b = input()
c = input()

i = "a"
player = {"a":a,"b":b,"c":c}

while True:
    if len(player[i])==0:
        print(i.upper())
        break
    l = player[i][0]
    player[i] = player[i][1:]
    i = l
Buggy code:
A = input()
B = input()
C = input()
T = "a"
while not ((A=="" and T=="a") and (B==""and T=="b") and (C==""and T=="c")):
  if T =="a":
    T = A[0]
    A = A[1:]
  elif T =="b":
    T = B[0]
    B = B[1:]
  elif T =="c":
    T = C[0]
    C = C[1:]
if (A==""):
  print("a")
elif (B==""):
  print("b")
elif (C==""):
  print("c")

Fixed code:
A = input()
B = input()
C = input()
T = "a"
while  not ((A=="" and T=="a") or (B=="" and T=="b") or (C=="" and T=="c")):
  if T =="a":
    T = A[0]
    A = A[1:]
  elif T =="b":
    T = B[0]
    B = B[1:]
  elif T =="c":
    T = C[0]
    C = C[1:]
if (A=="" and T=="a"):
  print("A")
elif (B=="" and T=="b"):
  print("B")
elif (C=="" and T=="c"):
  print("C")
Buggy code:
a = input()
b = input()
c = input()
first_str = a[0]
a = a[1:]
while(1):
  if first_str == 'a':
    first_str = a[0]
    a = a[1:]
    if len(a)==0:
      print('A')
      break
  elif first_str == 'b':
    first_str = b[0]
    b = b[1:]
    if len(b)==0:
      print('B')
      break
  elif first_str == 'c':
    first_str = c[0]
    c = c[1:]
    if len(c)==0:
      print('C')
      break
  
    

Fixed code:
a = input()
b = input()
c = input()
first_str = a[0]
a = a[1:]
while(1):
  if first_str == 'a':
    if len(a)==0:
      print('A')
      break
    first_str = a[0]
    a = a[1:]
    
  elif first_str == 'b':
    if len(b)==0:
      print('B')
      break
    first_str = b[0]
    b = b[1:]
    
  elif first_str == 'c':
    if len(c)==0:
      print('C')
      break
    first_str = c[0]
    c = c[1:]
Buggy code:
turn = "a"
S = {}
S["a"] = list(input())
S["b"] = list(input())
S["c"] = list(input())

while True:
    nextturn = S[turn].pop(0)
    if len(S[turn]) == 0:
        print(turn.upper())
        break
    else:
        turn = nextturn
        

Fixed code:
turn = "a"
S = {}
S["a"] = list(input())
S["b"] = list(input())
S["c"] = list(input())

while True:
    turn = S[turn].pop(0)
    if len(S[turn]) == 0:
        print(turn.upper())
        break
Buggy code:
from collections import deque

m = [deque(input()) for _ in range(3)]
t = 0

while True:
  if len(m[t]) == 1:
    print('ABC'[t])
    break
  
  t = 'abc'.find(m[t].popleft())


Fixed code:
from collections import deque

m = [deque(input()) for _ in range(3)]
t = 0

while True:
  if len(m[t]) == 0:
    print('ABC'[t])
    break
  
  t = 'abc'.find(m[t].popleft())
Buggy code:
strin = [input(), input(), input()]
l = ['a','b','c']
cnt, nxt = [0, 0, 0], 0
while True:
    lttr = strin[nxt][cnt[nxt]]
    cnt[nxt] += 1
    if cnt[nxt] >= len(strin[nxt]):
        print(l[nxt].upper())
    nxt = l.index(lttr)


Fixed code:
strin = [input(), input(), input()]
l = ['a','b','c']
cnt, nxt = [0, 0, 0], 0
while True:
    lttr = strin[nxt][cnt[nxt]]
    cnt[nxt] += 1
    nxt = l.index(lttr)
    if cnt[nxt] >= len(strin[nxt]):
        print(l[nxt].upper())
        break
Buggy code:
a = input()
b = input()
c = input()
ac = 0
bc = 0
cc = 0
curr = 'a'
while ac < len(a) and bc < len(b) and cc < len(c):
    if curr == 'a':
        curr = a[ac]
        ac += 1
    elif curr == 'b':
        curr = b[bc]
        bc += 1
    elif curr == 'c':
        curr = c[cc]
        cc += 1

if ac == 0:
    print("A")
elif bc == 0:
    print("B")
else:
    print("C")


Fixed code:
a = input()
b = input()
c = input()
ac = 0
bc = 0
cc = 0
curr = 'a'
while ac <= len(a) and bc <= len(b) and cc <= len(c):
    if curr == 'a':
        if ac == len(a):
            print("A")
            break
        curr = a[ac]
        ac += 1
    elif curr == 'b':
        if bc == len(b):
            print("B")
            break
        curr = b[bc]
        bc += 1
    elif curr == 'c':
        if cc == len(c):
            print("C")
            break
        curr = c[cc]
        cc += 1
Buggy code:
s={'a': input(), 'b': input(), 'c' input()}
now='a'
while s[now]!="":
  next =s[now][0]
  s[now]=s[now][1:]
  now= next
print(now.upper())

Fixed code:
s = {'a': input(), 'b': input(), 'c': input()}
 
now = 'a'
while s[now] != '':
    next = s[now][0]
    s[now] = s[now][1:]
    now = next
print(now.upper())
Buggy code:
A = list(str(input()))
B = list(str(input()))
C = list(str(input()))
a_len = len(A)
b_len = len(B)
c_len = len(C)
next = "A"

while a_len>=0 and b_len>=0 and c_len>=0:
    if next=="A":
        next = A[0]
        del A[0]
        a_len -= 1
    elif next=="B":
        next = B[0]
        del B[0]
        b_len -= 1
    else:
        next = C[0]
        del C[0]
        c_len -= 1
print(next.upper())

Fixed code:
A = list(str(input()))
B = list(str(input()))
C = list(str(input()))
a_len = len(A)
b_len = len(B)
c_len = len(C)
next = "a"

while a_len>=0 and b_len>=0 and c_len>=0:
    if next=="a":
        if a_len>=1:
            next = A[0]
            del A[0]
        a_len -= 1
    elif next=="b":
        if b_len>=1:
            next = B[0]
            del B[0]
        b_len -= 1
    else:
        if c_len>=1:
            next = C[0]
            del C[0]
        c_len -= 1
print(next.upper())
Buggy code:
A = [i for i in input()]
B = [i for i in input()]
C = [i for i in input()]

turn = 'a'
while True:

    if turn == 'a':
        try:
            turn = A.pop()
        except:
            print('A')
            exit(0)
    elif turn == 'b':
        try:
            turn = A.pop()
        except:
            print('A')
            exit(0)
    elif turn == 'c':
        try:
            turn = A.pop()
        except:
            print('A')
            exit(0)





Fixed code:
A = [i for i in input()]
B = [i for i in input()]
C = [i for i in input()]

turn = 'a'
while True:

    if turn == 'a':
        try:
            turn = A.pop(0)
        except:
            print('A')
            exit(0)
    elif turn == 'b':
        try:
            turn = B.pop(0)
        except:
            print('B')
            exit(0)
    elif turn == 'c':
        try:
            turn = C.pop(0)
        except:
            print('C')
            exit(0)
Buggy code:
s0 = list(input())
s1 = list(input())
s2 = list(input())
s = [s0, s1, s2]
m = 0

for _ in range(301):
    if s[m]:
        if s[m][0] == "A":
            m = 0
        elif s[m][0] == "B":
            m = 1
        else:
            m = 2 
        del s[m][0]    
    else:
        if m == 0:
            print("A")
        elif m == 1:
            print("B")
        else:
            print("C")
        break

        


Fixed code:
s0 = list(input())
s1 = list(input())
s2 = list(input())
s = [s0, s1, s2]
m = 0

for _ in range(301):
    if s[m]:
        if s[m][0] == "a":
            del s[m][0]
            m = 0
        elif s[m][0] == "b":
            del s[m][0]
            m = 1
        else:
            del s[m][0]
            m = 2 
    else:
        if m == 0:
            print("A")
        elif m == 1:
            print("B")
        else:
            print("C")
        break