object ITP109B extends App {

  while(true) {
    val cards = io.StdIn.readLine()
    if(cards == "-") System.exit(0)

    var sb = StringBuilder.newBuilder
    val buf = StringBuilder.newBuilder

    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()
    }

    println(sb)
  }
}

