import java.util.Scanner;

class Main {
	public static void main(String args[]){	
		Scanner scan = new Scanner(System.in);
				
		int m, n, h;
		String str;
		
		while(true){
			str = scan.next();
			if(str.equals("-"))break;
			
			n = str.length(); //??????????????°???????????°???
			
			m = scan.nextInt(); //?????£??????????????°
			
			for(int i = 0; i < m; i++){
				h = scan.nextInt(); //????????? h ????????????

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			}
			
			System.out.println(str);
		}
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String args[]){	
		Scanner scan = new Scanner(System.in);
				
		int m, n, h;
		String str;
		
		while(true){
			str = scan.next();
			if(str.equals("-"))break;
			
			n = str.length(); //??????????????°???????????°???
			
			m = scan.nextInt(); //?????£??????????????°
			
			for(int i = 0; i < m; i++){
				h = scan.nextInt(); //????????? h ????????????

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

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			}
			
			System.out.println(str);
		}
	} main {	
		Scanner scan = new Scanner(System.in);
				
		int m, n, h;
		String str;
		
		while(true){
			str = scan.next();
			if(str.equals("-"))break;
			
			n = str.length(); //??????????????°???????????°???
			
			m = scan.nextInt(); //?????£??????????????°
			
			for(int i = 0; i < m; i++){
				h = scan.nextInt(); //????????? h ????????????

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			}
			
			System.out.println(str);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int m m n n h; h String str; str while(true){
			str = scan.next();
			if(str.equals("-"))break;
			
			n = str.length(); //??????????????°???????????°???
			
			m = scan.nextInt(); //?????£??????????????°
			
			for(int i = 0; i < m; i++){
				h = scan.nextInt(); //????????? h ????????????

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			}
			
			System.out.println(str);
		} true {
			str = scan.next();
			if(str.equals("-"))break;
			
			n = str.length(); //??????????????°???????????°???
			
			m = scan.nextInt(); //?????£??????????????°
			
			for(int i = 0; i < m; i++){
				h = scan.nextInt(); //????????? h ????????????

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			}
			
			System.out.println(str);
		} str = scan.next() str scan.next() scan.next scan if(str.equals("-"))break; str.equals("-") str.equals str "-" break; n = str.length() n str.length() str.length str m = scan.nextInt() m scan.nextInt() scan.nextInt scan for(int i = 0; i < m; i++){
				h = scan.nextInt(); //????????? h ????????????

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				h = scan.nextInt(); //????????? h ????????????

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			} {
				h = scan.nextInt(); //????????? h ????????????

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			} h = scan.nextInt() h scan.nextInt() scan.nextInt scan String sub = str.substring(0, h); sub str.substring(0, h) str.substring str 0 h String sub2 = str.substring(h); sub2 str.substring(h) str.substring str h str = sub2 str sub2 str += sub str sub System.out.println(str) System.out.println System.out System System.out str String args[] args
import java.util.Scanner;

class Main {
	public static void main(String args[]){	
		Scanner scan = new Scanner(System.in);
				
		int m, n, h;
		String str;
		
		while(true){
			str = scan.next();
			if(str.equals("-"))break;
			
			n = str.length(); //??????????????°???????????°???
			
			m = scan.nextInt(); //?????£??????????????°
			
			for(int i = 0; i < m; i++){
				h = scan.nextInt(); //????????? h ????????????

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			}
			
			System.out.println(str);
		}
	}
}