import scala.io.StdIn

object Main extends App {
  var loop = true
  while (loop) {
    var s = StdIn.readLine().toString
    if (s == "-") loop = false
    else {
      val m = StdIn.readInt()
      for (i <- 1 to m) {
        val (l, r) = s.splitAt(StdIn.readInt())
        s = r + l
      }
      println(s)
    }
  }
}