import scala.io.StdIn.{readLine, readInt}

object Main extends App {
  var continue = true
  while (continue) {
    var cards = readLine()
    if (cards == "-") {
      continue = false
    } else {
      val m = readInt()
      for (_ <- 1 to m) {
        val (first, second) = cards.splitAt(readInt())
        cards = second + first
      }
      println(cards)
    }
  }
}

