

object Main extends App{

  override def main(args : Array[String]) : Unit = {
    Iterator.continually(new Data(io.StdIn.readLine))
      .takeWhile(_.continue).map(_.solve).foreach(println(_))
      
  }
  
  class Data(word : String){
    val continue = word != "-"
    
    val num = if(continue) io.StdIn.readLine.toInt else 0
    val sum = (0 until num).map(_ => io.StdIn.readLine.toInt).reduceOption((z,n)=>z+n)
    
    def solve : String = {
      val len = word.length()
      val index = sum.get % len
      word.substring(index) + word.substring(0,index)     
    }
  }
}