fun main(args: Array<String>) {
    while (true) {
        val inputString = readLine()!!
        if (inputString == "-") break

        var deck = inputString
        for (i in (0 until readLine()!!.toInt())) {
            val num = readLine()!!.toInt()
            deck = deck.substring(num) + deck.substring(0, num)
        }
        println("$deck")
    }
}

