Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def FizzBuzz(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = FizzBuzz()
        for i in range(1, n+1):
            p = input().strip('\n')
            if p != fb.__next__():
                players.popleft()
            else:
                players.rotate(-1)
            if len(players) == 1:
                break

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Fixed submission:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        ok_count = 0
        for _ in range(n):
            p = input().strip()
            if p != fb.__next__():
                if len(players) > 1:
                    players.rotate(ok_count)
                    players.popleft()
                    ok_count = 0
            else:
                ok_count -= 1

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def FizzBuzz(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = FizzBuzz()
        for _ in range(n):
            p = input().strip('\n')
            # print('player {}: {}'.format(players[0], p))
            if p != fb.__next__():
                drop = players.popleft()
                # print('player {} dropped'.format(drop))
                if len(players) == 1:
                    break
            else:
                players.rotate(-1)

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Fixed submission:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        ok_count = 0
        for _ in range(n):
            p = input().strip()
            if p != fb.__next__():
                if len(players) > 1:
                    players.rotate(ok_count)
                    players.popleft()
                    ok_count = 0
            else:
                ok_count -= 1

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        for _ in range(n):
            p = input().strip()
            # print('player {}: {}'.format(players[0], p))
            if p != fb.__next__():
                drop = players.popleft()
                # print('player {} dropped'.format(drop))
                if len(players) == 1:
                    break
            else:
                players.rotate(-1)

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Fixed submission:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        ok_count = 0
        for _ in range(n):
            p = input().strip()
            if p != fb.__next__():
                if len(players) > 1:
                    players.rotate(ok_count)
                    players.popleft()
                    ok_count = 0
            else:
                ok_count -= 1

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        for _ in range(n):
            if len(players) == 1:
                break
            p = input().strip()
            if p != fb.__next__():
                players.popleft()
            else:
                players.rotate(-1)

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Fixed submission:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        ok_count = 0
        for _ in range(n):
            p = input().strip()
            if p != fb.__next__():
                if len(players) > 1:
                    players.rotate(ok_count)
                    players.popleft()
                    ok_count = 0
            else:
                ok_count -= 1

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        for _ in range(n):
            p = input().strip()
            if p != fb.__next__():
                try:
                    drop = players.popleft()
                except:
                    players = deque(drop)
                if len(players) == 1:
                    break
            else:
                players.rotate(-1)

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

Fixed submission:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        ok_count = 0
        for _ in range(n):
            p = input().strip()
            if p != fb.__next__():
                if len(players) > 1:
                    players.rotate(ok_count)
                    players.popleft()
                    ok_count = 0
            else:
                ok_count -= 1

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])