import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next();
			if(str.equals("-"))break;
			int m=in.nextInt();
			
			for(int i=0;i<m;i++) {
				int h=Integer.parseInt(in.next());
				String str1=str.substring(0, h),str2=str.substring(h);
				//out.println(str1+" "+str2);
				str=str2+str1;
			}
			out.println(str);
		}
		out.flush();
	}

}
 import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next();
			if(str.equals("-"))break;
			int m=in.nextInt();
			
			for(int i=0;i<m;i++) {
				int h=Integer.parseInt(in.next());
				String str1=str.substring(0, h),str2=str.substring(h);
				//out.println(str1+" "+str2);
				str=str2+str1;
			}
			out.println(str);
		}
		out.flush();
	}

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

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next();
			if(str.equals("-"))break;
			int m=in.nextInt();
			
			for(int i=0;i<m;i++) {
				int h=Integer.parseInt(in.next());
				String str1=str.substring(0, h),str2=str.substring(h);
				//out.println(str1+" "+str2);
				str=str2+str1;
			}
			out.println(str);
		}
		out.flush();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next();
			if(str.equals("-"))break;
			int m=in.nextInt();
			
			for(int i=0;i<m;i++) {
				int h=Integer.parseInt(in.next());
				String str1=str.substring(0, h),str2=str.substring(h);
				//out.println(str1+" "+str2);
				str=str2+str1;
			}
			out.println(str);
		}
		out.flush();
	}

} Main
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			String str=in.next();
			if(str.equals("-"))break;
			int m=in.nextInt();
			
			for(int i=0;i<m;i++) {
				int h=Integer.parseInt(in.next());
				String str1=str.substring(0, h),str2=str.substring(h);
				//out.println(str1+" "+str2);
				str=str2+str1;
			}
			out.println(str);
		}
		out.flush();
	}

}

