import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			}
			
			
			
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			}
			
			
			
		}
	}
} Main public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			}
			
			
			
		}
	} main {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			}
			
			
			
		}
	} try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			}
			
			
			
		} {
			while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			}
			
			
			
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			} true {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			} String str = sc.next(); str sc.next() sc.next sc if (str.equals("-"))	break; str.equals("-") str.equals str "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				} int i=0; int i=0; i 0 i<m i m i++ i++ i {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				} {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				} int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc String s = str.substring(h,str.length()) + str.substring(0,h); s str.substring(h,str.length()) + str.substring(0,h) str.substring(h,str.length()) str.substring str h str.length() str.length str str.substring(0,h) str.substring str 0 h str = s str s 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) {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			}
			
			
			
		}
	}
} public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			}
			
			
			
		}
	}
} Main
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				String str = sc.next();
				if (str.equals("-"))	break;
				
				int m = sc.nextInt();
				for(int i=0; i<m; i++) {
					int h = sc.nextInt();
					
					String s = str.substring(h,str.length()) + str.substring(0,h);
					str = s;
			//		System.out.println(str);
				}
				System.out.println(str);
			}
			
			
			
		}
	}
}
