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