import java.util.*

fun main(args:Array<String>?): Unit {
    while(true){
        val (m, n) = readLine()!!.trim().split(' ').map(String::toInt)
        if (m == 0) return
        val queue: Queue<Int> = LinkedList<Int>()
        for (i in 1 .. m) queue.add(i)
        for (i in 1 .. n){
            val s = readLine()!!.trim()
            if (queue.size == 1) continue
            if (i % 15 == 0){
                if (s == "FizzBuzz") queue.add(queue.poll())
                else queue.poll()
            }else if (i % 5 == 0){
                if (s == "Buzz") queue.add(queue.poll())
                else queue.poll()
            }else if (i % 3 == 0){
                if (s == "Fizz") queue.add(queue.poll())
                else queue.poll()
            }else {
                if (i.toString() == s) queue.add(queue.poll())
                else queue.poll()
            }
        }
        println(queue.sorted().joinToString(" "))
    }
}
