import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		}
	}

	private static String doShuffle(String text, int[] shuffle) {

		for(int num : shuffle) {
			text = text.substring(num) + text.substring(0, num);
		}
		return text;
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		}
	}

	private static String doShuffle(String text, int[] shuffle) {

		for(int num : shuffle) {
			text = text.substring(num) + text.substring(0, num);
		}
		return text;
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		}
	} main {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		} true {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		} String start = sc.nextLine(); start sc.nextLine() sc.nextLine sc if(start.equals("-")) break; start.equals("-") start.equals start "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] shuffle = new int[m]; shuffle new int[m] m for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				shuffle[i] = sc.nextInt();
			} {
				shuffle[i] = sc.nextInt();
			} shuffle[i] = sc.nextInt() shuffle[i] shuffle i sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc String ans = doShuffle(start, shuffle); ans doShuffle(start, shuffle) doShuffle start shuffle System.out.println(ans) System.out.println System.out System System.out ans String[] args args private static String doShuffle(String text, int[] shuffle) {

		for(int num : shuffle) {
			text = text.substring(num) + text.substring(0, num);
		}
		return text;
	} doShuffle {

		for(int num : shuffle) {
			text = text.substring(num) + text.substring(0, num);
		}
		return text;
	} for(int num : shuffle) {
			text = text.substring(num) + text.substring(0, num);
		} int num shuffle {
			text = text.substring(num) + text.substring(0, num);
		} {
			text = text.substring(num) + text.substring(0, num);
		} text = text.substring(num) + text.substring(0, num) text text.substring(num) + text.substring(0, num) text.substring(num) text.substring text num text.substring(0, num) text.substring text 0 num return text; text String text text int[] shuffle shuffle public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		}
	}

	private static String doShuffle(String text, int[] shuffle) {

		for(int num : shuffle) {
			text = text.substring(num) + text.substring(0, num);
		}
		return text;
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		}
	}

	private static String doShuffle(String text, int[] shuffle) {

		for(int num : shuffle) {
			text = text.substring(num) + text.substring(0, num);
		}
		return text;
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		}
	}

	private static String doShuffle(String text, int[] shuffle) {

		for(int num : shuffle) {
			text = text.substring(num) + text.substring(0, num);
		}
		return text;
	}
}