import scala.io.StdIn

object Main extends App {

  var text = ""
  do {
    if(text != ""){
      var shuffleCnt = Integer.parseInt(StdIn.readLine())

      (0 until shuffleCnt).foreach{ _ =>
        val splitAt = Integer.parseInt(StdIn.readLine())
        text = text.slice(splitAt, text.length) + text.slice(0, splitAt)
      }
      println(text)
    }
    text = StdIn.readLine()
  } while(text != "-")
  
}
