import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		char[] s;
		char tmp;
		int m,h;
		while(true){
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		}
		scan.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		char[] s;
		char tmp;
		int m,h;
		while(true){
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		}
		scan.close();
	}
} Main public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		char[] s;
		char tmp;
		int m,h;
		while(true){
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		}
		scan.close();
	} main {
		Scanner scan=new Scanner(System.in);
		char[] s;
		char tmp;
		int m,h;
		while(true){
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		}
		scan.close();
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) char[] s; s char tmp; tmp int m m h; h while(true){
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		} true {
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		} s=scan.next().toCharArray() s scan.next().toCharArray() scan.next().toCharArray scan.next() scan.next scan if(s[0]=='-') break; s[0]=='-' s[0] s 0 '-' break; m=scan.nextInt() m scan.nextInt() scan.nextInt scan for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			} int i=0; int i=0; i 0 i<m i m i++ i++ i {
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			} {
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			} h=scan.nextInt() h scan.nextInt() scan.nextInt scan for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				} int j=0; int j=0; j 0 j<h j h j++ j++ j {
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				} {
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				} tmp=s[0] tmp s[0] s 0 for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					} int k=0; int k=0; k 0 k<s.length-1 k s.length-1 s.length s s.length 1 k++ k++ k {
						s[k]=s[k+1];
					} {
						s[k]=s[k+1];
					} s[k]=s[k+1] s[k] s k s[k+1] s k+1 k 1 s[s.length-1]=tmp s[s.length-1] s s.length-1 s.length s s.length 1 tmp for(int i=0;i<s.length;i++) System.out.print(s[i]); int i=0; int i=0; i 0 i<s.length i s.length s s.length i++ i++ i System.out.print(s[i]); System.out.print(s[i]) System.out.print System.out System System.out s[i] s i System.out.println() System.out.println System.out System System.out scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		char[] s;
		char tmp;
		int m,h;
		while(true){
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		}
		scan.close();
	}
} public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		char[] s;
		char tmp;
		int m,h;
		while(true){
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		}
		scan.close();
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		char[] s;
		char tmp;
		int m,h;
		while(true){
			s=scan.next().toCharArray();
			if(s[0]=='-') break;
			m=scan.nextInt();
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					tmp=s[0];
					for(int k=0;k<s.length-1;k++){
						s[k]=s[k+1];
					}
					s[s.length-1]=tmp;
				}
			}
			for(int i=0;i<s.length;i++) System.out.print(s[i]);
			System.out.println();
		}
		scan.close();
	}
}