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