import java.util.*

fun shuffle(cards: String, h: Int)= cards.drop(h) + cards.take(h)

fun shuffle(cards: String, vararg h: Int): String =
    if (h.isEmpty()) cards else
        shuffle(shuffle(cards, h.first()), *h.drop(1).toIntArray())

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val answers = mutableListOf<String>()
    while (true) {
        val cards = scanner.next()
        if (cards == "-") {
            break
        }
        val m = scanner.nextInt()
        val list = mutableListOf<Int>()
        (1..m).forEach {
            list.add(scanner.nextInt())
        }
        answers.add(shuffle(cards, *list.toIntArray()))
    }
    answers.forEach { println(it) }
}

