
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);
		}
	}
} import java.util.Scanner; Scanner java.util 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);
		}
	}
} 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);
		}
	} main {
		/*
		 * ????????????????????¨???????????? 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);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String cardSet; cardSet int shuffleM shuffleM shuffleH; shuffleH 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);
		} 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);
		} cardSet=sc.next() cardSet sc.next() sc.next sc if(cardSet.equals("-"))break; cardSet.equals("-") cardSet.equals cardSet "-" break; shuffleM = sc.nextInt() shuffleM sc.nextInt() sc.nextInt sc for (int i = 0; i < shuffleM; i++) {
				shuffleH = sc.nextInt();
				// Shuffle
				cardSet = cardSet.substring(shuffleH) + cardSet.substring(0, shuffleH);
			} int i = 0; int i = 0; i 0 i < shuffleM i shuffleM i++ i++ i {
				shuffleH = sc.nextInt();
				// Shuffle
				cardSet = cardSet.substring(shuffleH) + cardSet.substring(0, shuffleH);
			} {
				shuffleH = sc.nextInt();
				// Shuffle
				cardSet = cardSet.substring(shuffleH) + cardSet.substring(0, shuffleH);
			} shuffleH = sc.nextInt() shuffleH sc.nextInt() sc.nextInt sc cardSet = cardSet.substring(shuffleH) + cardSet.substring(0, shuffleH) cardSet cardSet.substring(shuffleH) + cardSet.substring(0, shuffleH) cardSet.substring(shuffleH) cardSet.substring cardSet shuffleH cardSet.substring(0, shuffleH) cardSet.substring cardSet 0 shuffleH System.out.println(cardSet) System.out.println System.out System System.out cardSet String[] args args 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);
		}
	}
} 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);
		}
	}
} Main

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);
		}
	}
}