FB = (1..15).map{|x|[[:Fizz][x%3],[:Buzz][x%5]]*''}
loop do
  m, n = gets.split.map(&:to_i)
  break if m == 0
  pos = []
  ret = Array.new(m){|i|i+1}
  (FB*(n/15)+FB[0,n%15]).map.with_index{|v,i| v==''? (i+1).to_s : v}.zip(n.times.map{gets.chomp}).map.with_index{|(a,b),i| i if a!=b}.compact[0,m-1].unshift(0).each_cons(2).with_index{|(a,b),i| pos << (b-a)%(m-i)}
  pos.reduce(0){|s,t| ret.slice!(t=(s+t)%ret.size); t-1}
  puts ret.join(' ')
end 