"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	while(true){
		var cards = lines.shift();
		if(cards == "-") break;
		var times = +lines.shift();
		var sum = 0;
		for(var i=0;i<times;i++) sum += +lines.shift();
		sum %= cards.length;
		console.log(cards.slice(sum) + cards.slice(0, sum));
	}
}