import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		}
	}
} import java.util.*; util.* java public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		}
	}
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
		while (true) {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		}
	} main {
		while (true) {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		}
	} while (true) {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		} true {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		} StringBuilder sb = new StringBuilder(sc.next()); sb new StringBuilder(sc.next()) if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			} sb.toString().equals("-") sb.toString().equals sb.toString() sb.toString sb "-" {break;} break; {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				} int i=0; int i=0; i 0 i<n i n i++ i++ i {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				} {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				} int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc String s = sb.substring(0,a); s sb.substring(0,a) sb.substring sb 0 a sb.delete(0,a) sb.delete sb 0 a sb.append(s) sb.append sb s System.out.println(sb) System.out.println System.out System System.out sb String[] args args public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		}
	}
} public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		}
	}
} Main
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			StringBuilder sb = new StringBuilder(sc.next());
			if (sb.toString().equals("-")) {break;}
			else {
				int n = sc.nextInt();
				for (int i=0; i<n; i++) {
					int a = sc.nextInt();
					String s = sb.substring(0,a);
					sb.delete(0,a);
					sb.append(s);
				}
				System.out.println(sb);
			}
		}
	}
}
