import scala.io.Source

object Main extends App {
  val src = Source.stdin.getLines

  def shuffleCards(sx: List[String] = Nil): List[String] = {
    val originalOrder = src.next

    if (originalOrder == "-") sx
    else {
      val suffleNumber = src.next.toInt

      def shuffle(times: Int, str : String): String = {
        if (times > 0) {
          val splitCardNum = src.next.toInt
          shuffle(times - 1, str.drop(splitCardNum) + str.take(splitCardNum))
        } else str
      }

      shuffleCards(sx :+ shuffle(suffleNumber, originalOrder))
    }
  }
  shuffleCards().foreach(println)
}