import java.io._

object Main extends App {

  val out = new PrintWriter(System.out,true)
  val buf = StringBuilder.newBuilder
  var sb = StringBuilder.newBuilder
  var isContinue = true

  while(isContinue) {
    val cards = io.StdIn.readLine()
    if(cards != "-") {

      sb.append(cards)
      val cnt = io.StdIn.readInt()
      for(_ <- 1 to cnt) {
        val h = io.StdIn.readInt()
        buf.append(sb.substring(h)).append(sb.substring(0,h))
        sb.clear()
        sb.append(buf)
        buf.clear()
      }

      out.println(sb)
      sb.clear()
    }
    else isContinue = false
  }
  out.flush()
}

