import scala.io.StdIn._

object Main {
  def replaceCard(l: List[String] = Nil): List[String] = {
    val originCard = readLine()

    if (originCard == "-") l
    else {
      val shuffleNum = readInt()

      def loop(n: Int, s: String): String = {
        if (n > 0) {
          val replaceCardNum = readInt()
          loop(n - 1, s.drop(replaceCardNum) + s.take(replaceCardNum))
        } else s
      }

      replaceCard(l :+ loop(shuffleNum, originCard))
    }
  }

  def main(args: Array[String]): Unit = {
    replaceCard().foreach(println)
  }
}