object Main extends App {
  val sc = new java.util.Scanner(System.in)

  while (sc.hasNext) {
    val cards = sc.next()
    val hList = List.fill(sc.nextInt())(sc.nextInt())
    val shuffle = makeShuffleFun(cards)
    cards match {
      case "-" => sc.close()
      case _ =>
        hList.foreach(shuffle(_))
        println(shuffle(0))
    }
  }

  def makeShuffleFun(c: String): (Int) => String = {
    var cards = c
    (h: Int) => {
      if (h != 0) cards = cards.drop(h) ++ cards.take(h)
      cards
    }
  }
}