import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		int i, j, m, h, length;
		String str1, str2;
		char c1[], c2[];
		Scanner sc = new Scanner(System.in);
		while (true) {
			str1 = sc.next();
			if (str1.equals("-")) {
				break;
			}
			length = str1.length();
			m = sc.nextInt();
			for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			}
			System.out.println(str1);
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String args[]) {
		int i, j, m, h, length;
		String str1, str2;
		char c1[], c2[];
		Scanner sc = new Scanner(System.in);
		while (true) {
			str1 = sc.next();
			if (str1.equals("-")) {
				break;
			}
			length = str1.length();
			m = sc.nextInt();
			for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			}
			System.out.println(str1);
		}
		sc.close();
	}
} Main public static void main(String args[]) {
		int i, j, m, h, length;
		String str1, str2;
		char c1[], c2[];
		Scanner sc = new Scanner(System.in);
		while (true) {
			str1 = sc.next();
			if (str1.equals("-")) {
				break;
			}
			length = str1.length();
			m = sc.nextInt();
			for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			}
			System.out.println(str1);
		}
		sc.close();
	} main {
		int i, j, m, h, length;
		String str1, str2;
		char c1[], c2[];
		Scanner sc = new Scanner(System.in);
		while (true) {
			str1 = sc.next();
			if (str1.equals("-")) {
				break;
			}
			length = str1.length();
			m = sc.nextInt();
			for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			}
			System.out.println(str1);
		}
		sc.close();
	} int i i j j m m h h length; length String str1 str1 str2; str2 char c1[] c1 c2[]; c2 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			str1 = sc.next();
			if (str1.equals("-")) {
				break;
			}
			length = str1.length();
			m = sc.nextInt();
			for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			}
			System.out.println(str1);
		} true {
			str1 = sc.next();
			if (str1.equals("-")) {
				break;
			}
			length = str1.length();
			m = sc.nextInt();
			for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			}
			System.out.println(str1);
		} str1 = sc.next() str1 sc.next() sc.next sc if (str1.equals("-")) {
				break;
			} str1.equals("-") str1.equals str1 "-" {
				break;
			} break; length = str1.length() length str1.length() str1.length str1 m = sc.nextInt() m sc.nextInt() sc.nextInt sc for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			} i = 0; i = 0 i 0 i < m i m ++i ++i i {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			} {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			} h = sc.nextInt() h sc.nextInt() sc.nextInt sc c1 = new char[h] c1 new char[h] h for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				} j = 0; j = 0 j 0 j < h j h ++j ++j j {
					c1[j] = str1.charAt(j);
				} {
					c1[j] = str1.charAt(j);
				} c1[j] = str1.charAt(j) c1[j] c1 j str1.charAt(j) str1.charAt str1 j str2 = String.valueOf(c1) str2 String.valueOf(c1) String.valueOf String c1 c2 = new char[length - h] c2 new char[length - h] length - h length h int k = 0; k 0 for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				} j = h; j = h j h j < length j length ++j ++j j {
					c2[k] = str1.charAt(j);
					++k;
				} {
					c2[k] = str1.charAt(j);
					++k;
				} c2[k] = str1.charAt(j) c2[k] c2 k str1.charAt(j) str1.charAt str1 j ++k k str1 = String.valueOf(c2) str1 String.valueOf(c2) String.valueOf String c2 str1 = str1 + str2 str1 str1 + str2 str1 str2 System.out.println(str1) System.out.println System.out System System.out str1 sc.close() sc.close sc String args[] args public class Main {
	public static void main(String args[]) {
		int i, j, m, h, length;
		String str1, str2;
		char c1[], c2[];
		Scanner sc = new Scanner(System.in);
		while (true) {
			str1 = sc.next();
			if (str1.equals("-")) {
				break;
			}
			length = str1.length();
			m = sc.nextInt();
			for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			}
			System.out.println(str1);
		}
		sc.close();
	}
} public class Main {
	public static void main(String args[]) {
		int i, j, m, h, length;
		String str1, str2;
		char c1[], c2[];
		Scanner sc = new Scanner(System.in);
		while (true) {
			str1 = sc.next();
			if (str1.equals("-")) {
				break;
			}
			length = str1.length();
			m = sc.nextInt();
			for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			}
			System.out.println(str1);
		}
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		int i, j, m, h, length;
		String str1, str2;
		char c1[], c2[];
		Scanner sc = new Scanner(System.in);
		while (true) {
			str1 = sc.next();
			if (str1.equals("-")) {
				break;
			}
			length = str1.length();
			m = sc.nextInt();
			for (i = 0; i < m; ++i) {
				h = sc.nextInt();
				c1 = new char[h];
				for (j = 0; j < h; ++j) {
					c1[j] = str1.charAt(j);
				}
				str2 = String.valueOf(c1);
				c2 = new char[length - h];
				int k = 0;
				for (j = h; j < length; ++j) {
					c2[k] = str1.charAt(j);
					++k;
				}
				str1 = String.valueOf(c2);
				str1 = str1 + str2;
			}
			System.out.println(str1);
		}
		sc.close();
	}
}
