import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private static String[] chara;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		Boolean isEnd = str.equals("-");
		while (!isEnd) {
			String defaultstr = str;
			str = br.readLine();
			int count = Integer.parseInt(str);
			int[] shuffleamount = new int[count];
			for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			}
			chara = defaultstr.split("", 0);
			int length = chara.length;
			for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			}
			for (String charac : chara) {
				System.out.print(charac);
			}
			System.out.println();
			str = br.readLine();
			isEnd = str.equals("-");
		}
	}

	private static void Shuffling(int h, int l) {
		String[] temporary = new String[h];
		for (int k = 0; k < h; k++) {
			temporary[k] = chara[k];
		}
		for (int m = 0; m < l - h; m++) {
			chara[m] = chara[h + m];
		}
		for (int n = 0; n < h; n++) {
			chara[l - h + n] = temporary[n];
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	private static String[] chara;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		Boolean isEnd = str.equals("-");
		while (!isEnd) {
			String defaultstr = str;
			str = br.readLine();
			int count = Integer.parseInt(str);
			int[] shuffleamount = new int[count];
			for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			}
			chara = defaultstr.split("", 0);
			int length = chara.length;
			for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			}
			for (String charac : chara) {
				System.out.print(charac);
			}
			System.out.println();
			str = br.readLine();
			isEnd = str.equals("-");
		}
	}

	private static void Shuffling(int h, int l) {
		String[] temporary = new String[h];
		for (int k = 0; k < h; k++) {
			temporary[k] = chara[k];
		}
		for (int m = 0; m < l - h; m++) {
			chara[m] = chara[h + m];
		}
		for (int n = 0; n < h; n++) {
			chara[l - h + n] = temporary[n];
		}
	}
} Main private static String[] chara; chara public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		Boolean isEnd = str.equals("-");
		while (!isEnd) {
			String defaultstr = str;
			str = br.readLine();
			int count = Integer.parseInt(str);
			int[] shuffleamount = new int[count];
			for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			}
			chara = defaultstr.split("", 0);
			int length = chara.length;
			for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			}
			for (String charac : chara) {
				System.out.print(charac);
			}
			System.out.println();
			str = br.readLine();
			isEnd = str.equals("-");
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		Boolean isEnd = str.equals("-");
		while (!isEnd) {
			String defaultstr = str;
			str = br.readLine();
			int count = Integer.parseInt(str);
			int[] shuffleamount = new int[count];
			for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			}
			chara = defaultstr.split("", 0);
			int length = chara.length;
			for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			}
			for (String charac : chara) {
				System.out.print(charac);
			}
			System.out.println();
			str = br.readLine();
			isEnd = str.equals("-");
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br Boolean isEnd = str.equals("-"); isEnd str.equals("-") str.equals str "-" while (!isEnd) {
			String defaultstr = str;
			str = br.readLine();
			int count = Integer.parseInt(str);
			int[] shuffleamount = new int[count];
			for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			}
			chara = defaultstr.split("", 0);
			int length = chara.length;
			for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			}
			for (String charac : chara) {
				System.out.print(charac);
			}
			System.out.println();
			str = br.readLine();
			isEnd = str.equals("-");
		} !isEnd isEnd {
			String defaultstr = str;
			str = br.readLine();
			int count = Integer.parseInt(str);
			int[] shuffleamount = new int[count];
			for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			}
			chara = defaultstr.split("", 0);
			int length = chara.length;
			for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			}
			for (String charac : chara) {
				System.out.print(charac);
			}
			System.out.println();
			str = br.readLine();
			isEnd = str.equals("-");
		} String defaultstr = str; defaultstr str str = br.readLine() str br.readLine() br.readLine br int count = Integer.parseInt(str); count Integer.parseInt(str) Integer.parseInt Integer str int[] shuffleamount = new int[count]; shuffleamount new int[count] count for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			} int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			} {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			} str = br.readLine() str br.readLine() br.readLine br shuffleamount[i] = Integer.parseInt(str) shuffleamount[i] shuffleamount i Integer.parseInt(str) Integer.parseInt Integer str chara = defaultstr.split("", 0) chara defaultstr.split("", 0) defaultstr.split defaultstr "" 0 int length = chara.length; length chara.length chara chara.length for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			} int j = 0; int j = 0; j 0 j < count j count j++ j++ j {
				Shuffling(shuffleamount[j], length);
			} {
				Shuffling(shuffleamount[j], length);
			} Shuffling(shuffleamount[j], length) Shuffling shuffleamount[j] shuffleamount j length for (String charac : chara) {
				System.out.print(charac);
			} String charac chara {
				System.out.print(charac);
			} {
				System.out.print(charac);
			} System.out.print(charac) System.out.print System.out System System.out charac System.out.println() System.out.println System.out System System.out str = br.readLine() str br.readLine() br.readLine br isEnd = str.equals("-") isEnd str.equals("-") str.equals str "-" String[] args args private static void Shuffling(int h, int l) {
		String[] temporary = new String[h];
		for (int k = 0; k < h; k++) {
			temporary[k] = chara[k];
		}
		for (int m = 0; m < l - h; m++) {
			chara[m] = chara[h + m];
		}
		for (int n = 0; n < h; n++) {
			chara[l - h + n] = temporary[n];
		}
	} Shuffling {
		String[] temporary = new String[h];
		for (int k = 0; k < h; k++) {
			temporary[k] = chara[k];
		}
		for (int m = 0; m < l - h; m++) {
			chara[m] = chara[h + m];
		}
		for (int n = 0; n < h; n++) {
			chara[l - h + n] = temporary[n];
		}
	} String[] temporary = new String[h]; temporary new String[h] h for (int k = 0; k < h; k++) {
			temporary[k] = chara[k];
		} int k = 0; int k = 0; k 0 k < h k h k++ k++ k {
			temporary[k] = chara[k];
		} {
			temporary[k] = chara[k];
		} temporary[k] = chara[k] temporary[k] temporary k chara[k] chara k for (int m = 0; m < l - h; m++) {
			chara[m] = chara[h + m];
		} int m = 0; int m = 0; m 0 m < l - h m l - h l h m++ m++ m {
			chara[m] = chara[h + m];
		} {
			chara[m] = chara[h + m];
		} chara[m] = chara[h + m] chara[m] chara m chara[h + m] chara h + m h m for (int n = 0; n < h; n++) {
			chara[l - h + n] = temporary[n];
		} int n = 0; int n = 0; n 0 n < h n h n++ n++ n {
			chara[l - h + n] = temporary[n];
		} {
			chara[l - h + n] = temporary[n];
		} chara[l - h + n] = temporary[n] chara[l - h + n] chara l - h + n l - h l h n temporary[n] temporary n int h h int l l public class Main {
	private static String[] chara;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		Boolean isEnd = str.equals("-");
		while (!isEnd) {
			String defaultstr = str;
			str = br.readLine();
			int count = Integer.parseInt(str);
			int[] shuffleamount = new int[count];
			for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			}
			chara = defaultstr.split("", 0);
			int length = chara.length;
			for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			}
			for (String charac : chara) {
				System.out.print(charac);
			}
			System.out.println();
			str = br.readLine();
			isEnd = str.equals("-");
		}
	}

	private static void Shuffling(int h, int l) {
		String[] temporary = new String[h];
		for (int k = 0; k < h; k++) {
			temporary[k] = chara[k];
		}
		for (int m = 0; m < l - h; m++) {
			chara[m] = chara[h + m];
		}
		for (int n = 0; n < h; n++) {
			chara[l - h + n] = temporary[n];
		}
	}
} public class Main {
	private static String[] chara;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		Boolean isEnd = str.equals("-");
		while (!isEnd) {
			String defaultstr = str;
			str = br.readLine();
			int count = Integer.parseInt(str);
			int[] shuffleamount = new int[count];
			for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			}
			chara = defaultstr.split("", 0);
			int length = chara.length;
			for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			}
			for (String charac : chara) {
				System.out.print(charac);
			}
			System.out.println();
			str = br.readLine();
			isEnd = str.equals("-");
		}
	}

	private static void Shuffling(int h, int l) {
		String[] temporary = new String[h];
		for (int k = 0; k < h; k++) {
			temporary[k] = chara[k];
		}
		for (int m = 0; m < l - h; m++) {
			chara[m] = chara[h + m];
		}
		for (int n = 0; n < h; n++) {
			chara[l - h + n] = temporary[n];
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private static String[] chara;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		Boolean isEnd = str.equals("-");
		while (!isEnd) {
			String defaultstr = str;
			str = br.readLine();
			int count = Integer.parseInt(str);
			int[] shuffleamount = new int[count];
			for (int i = 0; i < count; i++) {
				str = br.readLine();
				shuffleamount[i] = Integer.parseInt(str);
			}
			chara = defaultstr.split("", 0);
			int length = chara.length;
			for (int j = 0; j < count; j++) {
				Shuffling(shuffleamount[j], length);
			}
			for (String charac : chara) {
				System.out.print(charac);
			}
			System.out.println();
			str = br.readLine();
			isEnd = str.equals("-");
		}
	}

	private static void Shuffling(int h, int l) {
		String[] temporary = new String[h];
		for (int k = 0; k < h; k++) {
			temporary[k] = chara[k];
		}
		for (int m = 0; m < l - h; m++) {
			chara[m] = chara[h + m];
		}
		for (int n = 0; n < h; n++) {
			chara[l - h + n] = temporary[n];
		}
	}
}