def fizzbuzz(n)
	if n%3==0&&n%5==0 then return 'FizzBuzz' end
	if n%3==0 then return 'Fizz' end
	if n%5==0 then return 'Buzz' end
	return n.to_s
end
while(m,n=gets.split.map(&:to_i))!=[0,0]
	a=1.step(m).map.to_a
	c=0
	1.step(n){|i|
		if gets.chomp!=fizzbuzz(i) then a.delete_at(c) else c=(c+1)%a.length end
	}
	puts a.join(' ')
end