import scala.io.StdIn.{readLine,readInt}
 
object Main extends App {
 
 
  def exec(w:String):Unit =  {
    val len = w.length
 
    def shuffle(i:Int, cnt:Int):String =
      if(i == 0) (w drop (cnt%len))+(w take (cnt%len)) else { val m = readInt;shuffle(i-1, cnt+m) }
 
    if(w=="-") return else { val n = readInt;println(shuffle(n,0));exec(readLine) }
 
  }
  exec(readLine)
}