import java.util.Scanner;
public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		}
	}
} Main static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; k {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'} 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		}
	} main {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		}
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) while (true) {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		} true {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		} String W = stdIn.next(); W stdIn.next() stdIn.next stdIn if(W.equals("-")) {
				break;
			} W.equals("-") W.equals W "-" {
				break;
			} break; int m = stdIn.nextInt(); m stdIn.nextInt() stdIn.nextInt stdIn for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			} {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			} int h = stdIn.nextInt(); h stdIn.nextInt() stdIn.nextInt stdIn String s1 = W.substring(0, h); s1 W.substring(0, h) W.substring W 0 h String s2 = W.substring(h); s2 W.substring(h) W.substring W h W = s2 + s1 W s2 + s1 s2 s1 System.out.println(W) System.out.println System.out System System.out W String[] args args public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		}
	}
} public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		}
	}
} Main
import java.util.Scanner;
public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			String W = stdIn.next();
			if(W.equals("-")) {
				break;
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; i++) {
				int h = stdIn.nextInt();
				String s1 = W.substring(0, h);
				String s2 = W.substring(h);
				W = s2 + s1;
			}
			System.out.println(W);
		}
	}
}