import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			String str = scan.next();
			
			if(str.equals("-")) break;
			
			int m = scan.nextInt();
			
			int[] h = new int[m];
			for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			}
			
			StringBuilder str2 = new StringBuilder();
			str2.append(str);
			for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			}
			
			System.out.println(str2);
		}
		
	}

}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			String str = scan.next();
			
			if(str.equals("-")) break;
			
			int m = scan.nextInt();
			
			int[] h = new int[m];
			for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			}
			
			StringBuilder str2 = new StringBuilder();
			str2.append(str);
			for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			}
			
			System.out.println(str2);
		}
		
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			String str = scan.next();
			
			if(str.equals("-")) break;
			
			int m = scan.nextInt();
			
			int[] h = new int[m];
			for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			}
			
			StringBuilder str2 = new StringBuilder();
			str2.append(str);
			for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			}
			
			System.out.println(str2);
		}
		
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			String str = scan.next();
			
			if(str.equals("-")) break;
			
			int m = scan.nextInt();
			
			int[] h = new int[m];
			for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			}
			
			StringBuilder str2 = new StringBuilder();
			str2.append(str);
			for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			}
			
			System.out.println(str2);
		}
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true) {
			String str = scan.next();
			
			if(str.equals("-")) break;
			
			int m = scan.nextInt();
			
			int[] h = new int[m];
			for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			}
			
			StringBuilder str2 = new StringBuilder();
			str2.append(str);
			for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			}
			
			System.out.println(str2);
		} true {
			String str = scan.next();
			
			if(str.equals("-")) break;
			
			int m = scan.nextInt();
			
			int[] h = new int[m];
			for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			}
			
			StringBuilder str2 = new StringBuilder();
			str2.append(str);
			for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			}
			
			System.out.println(str2);
		} String str = scan.next(); str scan.next() scan.next scan if(str.equals("-")) break; str.equals("-") str.equals str "-" break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan int[] h = new int[m]; h new int[m] m for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				h[i] = scan.nextInt();
			} {
				h[i] = scan.nextInt();
			} h[i] = scan.nextInt() h[i] h i scan.nextInt() scan.nextInt scan StringBuilder str2 = new StringBuilder(); str2 new StringBuilder() str2.append(str) str2.append str2 str for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			} {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			} String str_temp = str2.substring(0, h[i]); str_temp str2.substring(0, h[i]) str2.substring str2 0 h[i] h i str2.delete(0, h[i]) str2.delete str2 0 h[i] h i str2.append(str_temp) str2.append str2 str_temp System.out.println(str2) System.out.println System.out System System.out str2 String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			String str = scan.next();
			
			if(str.equals("-")) break;
			
			int m = scan.nextInt();
			
			int[] h = new int[m];
			for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			}
			
			StringBuilder str2 = new StringBuilder();
			str2.append(str);
			for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			}
			
			System.out.println(str2);
		}
		
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			String str = scan.next();
			
			if(str.equals("-")) break;
			
			int m = scan.nextInt();
			
			int[] h = new int[m];
			for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			}
			
			StringBuilder str2 = new StringBuilder();
			str2.append(str);
			for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			}
			
			System.out.println(str2);
		}
		
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			String str = scan.next();
			
			if(str.equals("-")) break;
			
			int m = scan.nextInt();
			
			int[] h = new int[m];
			for(int i = 0; i < m; i++) {
				h[i] = scan.nextInt();
			}
			
			StringBuilder str2 = new StringBuilder();
			str2.append(str);
			for(int i = 0; i < m; i++) {
				String str_temp = str2.substring(0, h[i]);
				str2.delete(0, h[i]);
				str2.append(str_temp);
			}
			
			System.out.println(str2);
		}
		
	}

}

