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

object Main extends App {


  def exec(w:String):Unit =  {
    val len = w.length

    if(w=="-") return else {
      val n = readInt
      var cnt = 0

      for(i <- 1 to n) cnt += readInt
      println((w drop (cnt%len)) + (w take (cnt%len)))
      exec(readLine)
    }
  }

  exec(readLine)
}