import java.util.Scanner;

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

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