object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine())
      .takeWhile(_ != "-")
      .foreach { cards =>
        val m = io.StdIn.readInt()
        val shuffle = (for (_ <- 0 until m) yield io.StdIn.readInt()).sum
        val result = shuffle % cards.length match {
          case 0 => cards
          case i => cards.substring(i) + cards.substring(0, i)
        }
        println(result)
      }
  }
}