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

object Main extends App {

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

    def shuffle(i:Int):String = {
      val cnt = (for(j <- 0 until i) yield readInt).sum
      (w drop (cnt%len))+(w take (cnt%len))
    }

    if(w=="-") return else { val n = readInt;println(shuffle(n));val w = readLine ; exec(w) }
  }

  val w = readLine; exec(w)
}