import java.io._

object Main extends App {

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

  while(isContinue) {
    sb.append(io.StdIn.readLine)
    if(sb.toString != "-") {

      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
}

