object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    while(true) {
      val s = scanner.next
      if(s.equals("-")) System.exit(0)
      val m = scanner.nextInt
      val l = Seq.fill(m)(scanner.nextInt).sum % s.length
      println(s.substring(l, s.length) + s.substring(0, l))
    }
  }
}

