import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		}
		sc.close();
	}

} 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 s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		}
		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			String s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		} true {
			String s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		} String s = sc.next(); s sc.next() sc.next sc if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			} s.equals("-") s.equals s "-" {
				break;
			} break; {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			} int n = s.length(); n s.length() s.length s char[] alp = new char[n]; alp new char[n] n for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
					alp[i] = s.charAt(i);
				} {
					alp[i] = s.charAt(i);
				} alp[i] = s.charAt(i) alp[i] alp i s.charAt(i) s.charAt s i int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				} {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				} int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc char[] tmp = new char[h]; tmp new char[h] h for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					} int j = 0; int j = 0; j 0 j < h j h j++ j++ j {
						tmp[j] = alp[j];
					} {
						tmp[j] = alp[j];
					} tmp[j] = alp[j] tmp[j] tmp j alp[j] alp j for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					} int j = 0; int j = 0; j 0 j < n - h j n - h n h j++ j++ j {
						alp[j] = alp[j + h];
					} {
						alp[j] = alp[j + h];
					} alp[j] = alp[j + h] alp[j] alp j alp[j + h] alp j + h j h for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					} int j = 0; int j = 0; j 0 j < h j h j++ j++ j {
						alp[n - h + j] = tmp[j];
					} {
						alp[n - h + j] = tmp[j];
					} alp[n - h + j] = tmp[j] alp[n - h + j] alp n - h + j n - h n h j tmp[j] tmp j for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
					System.out.print(alp[i]);
				} {
					System.out.print(alp[i]);
				} System.out.print(alp[i]) System.out.print System.out System System.out alp[i] alp i System.out.println() System.out.println System.out System System.out sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		}
		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		}
		sc.close();
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		}
		sc.close();
	}

}
