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

object Main extends App {
  var w = ""

  def shuffle(cnt:Int, w:String):String = {
    if(cnt == 0) { w }
    else {
      val m = readInt
      shuffle(cnt-1, (w+(w take m)) drop m)
    }
  }

  while( { w = readLine.trim;w } != "-") {
    val n = readInt
    println(shuffle(n,w))
  }
}