object Main{
  def main(args:Array[String]) : Unit = {
    val sc = new java.util.Scanner(System.in)
    var ans = ""
    while (sc.hasNext){
      val st = sc.next
      if (st == "-"){
        return 
      }
      ans = st
      val m = sc.nextInt
      for (i <- 0 until m){
        val h = sc.nextInt
        ans = shaffle(ans, h)
      }
      println(ans)
    }
  }
  def shaffle(st: String, h: Int) : String = {
    st.slice(h, st.size) + st.slice(0, h)
  }
}