Buggy python submission (verdict: Runtime Error):
while True:
    m,n=map(int,raw_input().split())
    if m==n==0:
        break
    L=[]
    s=range(1,m+1)
    for i in range(1,n+1):
        if i%15==0:
            L.append("FizzBuzz")
        elif i%5==0:
            L.append("Buzz")
        elif i%3==0:
            L.append("Fizz")
        else:
            L.append(str(i))

    j=0
    for chars in L:
        t=raw_input()
        if t<>chars:
            del s[j%m]
        j+=1
    print " ".join([str(i) for i in s])

Fixed submission:
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))

Buggy python submission (verdict: Runtime Error):
m,n=map(int,raw_input().split())
if m==n==0:
    break
L=[]
s=range(1,m+1)
for i in range(1,n+1):
    if i%15==0:
        L.append("FizzBuzz")
    elif i%5==0:
        L.append("Buzz")
    elif i%3==0:
        L.append("Fizz")
    else:
        L.append(str(i))

j=0
for chars in L:
    t=raw_input()
    if t<>chars:
        del s[j%m]
    j+=1
print " ".join([str(i) for i in s])

Fixed submission:
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))

Buggy python submission (verdict: Runtime Error):
while True:
    m,n=map(int,raw_input().split())
    if m==n==0:
        break
    L=[]
    s=range(1,m+1)
    for i in range(1,n+1):
        if i%15==0:
            L.append("FizzBuzz")
        elif i%5==0:
            L.append("Buzz")
        elif i%3==0:
            L.append("Fizz")
        else:
            L.append(str(i))

    j=0
    for chars in L:
        t=raw_input()
        if t<>chars:
            del s[j%m]
        j+=1
    for i in s:
        print i

Fixed submission:
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))

Buggy python submission (verdict: Runtime Error):
while True:
    m,n=map(int,raw_input().split())
    if m==n==0:
        break
    L=[]
    S=range(1,m+1)
    for i in range(1,n+1):
        if i%15==0:
            L.append("FizzBuzz")
        elif i%5==0:
            L.append("Buzz")
        elif i%3==0:
            L.append("Fizz")
        else:
            L.append(str(i))

    j=0
    for char in L:
        t=raw_input()
        if len(S)==1:break
        if t<>char:
            del S[j%m]
        j+=1
    print " ".join([str(i) for i in S])

Fixed submission:
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))

Buggy python submission (verdict: Time Limit Exceeded):
while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
        if i%15==0:
            if c!="FizzBuzz":
                L[j]=0
        elif i%5==0:
            if c!="Buzz":
		L[j]=0
	elif i%3==0:
            if c!="Fizz":
		L[j]=0
        elif c<>str(i):
            L[j]=0
        j+=1
        while L[j%m]==0:
            j=(j+1)%m
        j%=m
    print " ".join([str(i) for i in L if i!=0])

Fixed submission:
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))

Buggy python submission (verdict: Time Limit Exceeded):
while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)==1:break
        if i%15==0:
            if c!="FizzBuzz":
                L[j]=0
        elif i%5==0:
            if c!="Buzz":
		L[j]=0
	elif i%3==0:
            if c!="Fizz":
                L[j]=0
        elif c<>str(i):
            L[j]=0
        j+=1
        while L[j%m]==0:
            j=(j+1)%m
        j%=m
    print " ".join([str(i) for i in L if i!=0])

Fixed submission:
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))

Buggy python submission (verdict: Runtime Error):
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    L=range(1,m+1)
    j=0
    if m==n==0:break
    for i in range(1,n+1):
	c=raw_input()
	if len(L)==1:break
        if Judge(i)!=c:
            del L[j]
            j%=len(L)
        else:
            j=(j+1)%len(L)
        print L
    print " ".join(map(str,L))

Fixed submission:
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))

Buggy python submission (verdict: Runtime Error):
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    L=range(1,m+1)
    j=0
    if m==n==0:break
    for i in range(1,n+1):
	c=raw_input()
	if len(L)==1:break
        if Judge(i)!=c:
            del L[j]
            j%=len(L)
        else:
            j=(j+1)%len(L)
    print " ".join(map(str,L))

Fixed submission:
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))