import java.util.Scanner

fun main(args:Array<String>){

    val cin = Scanner(System.`in`)

    while(true){
        var str = cin.next()
	    if(str == "-") break

	    val m = cin.nextInt()
	    var temp = str

	    for(i in 1..m){
	        var index = cin.nextInt()
	        temp = str.substring(index,str.length)
	        temp += str.substring(0,index)
	        str = temp
	    }
        println(temp)
    }
}
    

