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

object Main extends App {
  while (true) {
    val s = readLine
    if (s == "-") sys.exit()
    val n = readInt

    var deck = s.toCharArray
    for (_ <- 1 to n) {
      val shuffle = readInt
      val picked = deck.take(shuffle)
      val rest = deck.drop(shuffle)
      deck = rest ++ picked
    }
    println(deck.mkString)
  }

}
