
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		/*
		 * ????????????????????¨???????????? aabc String str [] =read();
		 * ?????£??????????????° m int cnt= 3;
		 * ?????????h???????????????????????¨??????????????????
		 * aabc
		 * int 1; m1
		 * int 2; h2
		 * int 1; h1
		 *
		 * syso(aabc) - if()break;
		 *
		 *
		 * int h = 3; string str = "abcdef";
		 * string left =str.substr(0,h); //abc
		 */

		Scanner sc = new Scanner(System.in);

		// declear variable
		String cardSet;
		int shuffleM,shuffleH;
		// while section
		while (true) {
			cardSet=sc.next();
			// break condition
			if(cardSet.equals("-"))break;
			// Shuffle chance
			shuffleM = sc.nextInt();
			for (int i = 0; i < shuffleM; i++) {
				shuffleH = sc.nextInt();
				// Shuffle
				cardSet = cardSet.substring(shuffleH) + cardSet.substring(0, shuffleH);
			}
			System.out.println(cardSet);
		}
	}
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz