import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str, str2;
		while (true) {
			str = sc.next();
			if (str.equals("-"))
				break;
			str2 = "";
			int shuffulNum = sc.nextInt();
			for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			}
			System.out.println(str);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str, str2;
		while (true) {
			str = sc.next();
			if (str.equals("-"))
				break;
			str2 = "";
			int shuffulNum = sc.nextInt();
			for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			}
			System.out.println(str);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str, str2;
		while (true) {
			str = sc.next();
			if (str.equals("-"))
				break;
			str2 = "";
			int shuffulNum = sc.nextInt();
			for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			}
			System.out.println(str);
		}
	} main {
		Scanner sc = new Scanner(System.in);

		String str, str2;
		while (true) {
			str = sc.next();
			if (str.equals("-"))
				break;
			str2 = "";
			int shuffulNum = sc.nextInt();
			for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			}
			System.out.println(str);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str str str2; str2 while (true) {
			str = sc.next();
			if (str.equals("-"))
				break;
			str2 = "";
			int shuffulNum = sc.nextInt();
			for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			}
			System.out.println(str);
		} true {
			str = sc.next();
			if (str.equals("-"))
				break;
			str2 = "";
			int shuffulNum = sc.nextInt();
			for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			}
			System.out.println(str);
		} str = sc.next() str sc.next() sc.next sc if (str.equals("-"))
				break; str.equals("-") str.equals str "-" break; str2 = "" str2 "" int shuffulNum = sc.nextInt(); shuffulNum sc.nextInt() sc.nextInt sc for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			} int i = 0; int i = 0; i 0 i < shuffulNum i shuffulNum i++ i++ i {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			} {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				} int j = n; int j = n; j n j < str.length() j str.length() str.length str j++ j++ j {
					str2 += str.charAt(j);
				} {
					str2 += str.charAt(j);
				} str2 += str.charAt(j) str2 str.charAt(j) str.charAt str j for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
					str2 += str.charAt(j);
				} {
					str2 += str.charAt(j);
				} str2 += str.charAt(j) str2 str.charAt(j) str.charAt str j str = str2 str str2 str2 = "" str2 "" System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str, str2;
		while (true) {
			str = sc.next();
			if (str.equals("-"))
				break;
			str2 = "";
			int shuffulNum = sc.nextInt();
			for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			}
			System.out.println(str);
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str, str2;
		while (true) {
			str = sc.next();
			if (str.equals("-"))
				break;
			str2 = "";
			int shuffulNum = sc.nextInt();
			for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			}
			System.out.println(str);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str, str2;
		while (true) {
			str = sc.next();
			if (str.equals("-"))
				break;
			str2 = "";
			int shuffulNum = sc.nextInt();
			for (int i = 0; i < shuffulNum; i++) {
				int n = sc.nextInt();
				for (int j = n; j < str.length(); j++) {
					str2 += str.charAt(j);
				}
				for (int j = 0; j < n; j++) {
					str2 += str.charAt(j);
				}
				str = str2;
				str2 = "";
			}
			System.out.println(str);
		}
	}
}