import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {
   while(true){
      var cards = StdIn.readLine()
      if(cards == "-"){return}
      val shuffleCount = StdIn.readInt()
      for(_ <- 1 to shuffleCount){
        val h = StdIn.readInt()
        cards = cards.substring(h) + cards.substring(0,h)
      }
      println(cards)
    }
  }
}