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

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

  def exec(w:String):Unit =
    if(w=="-") return else { val n = readInt;println(shuffle(n,w));exec(readLine) }

  exec(readLine)
}