import java.io.*;

public class Main{
	public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		

		while(true){
			String str = br.readLine();
			if(str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			}
			System.out.println(str);
		}
	}
} import java.io.*; io.* java public class Main{
	public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		

		while(true){
			String str = br.readLine();
			if(str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			}
			System.out.println(str);
		}
	}
} Main public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		

		while(true){
			String str = br.readLine();
			if(str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			}
			System.out.println(str);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		

		while(true){
			String str = br.readLine();
			if(str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			}
			System.out.println(str);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String str = br.readLine();
			if(str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			}
			System.out.println(str);
		} true {
			String str = br.readLine();
			if(str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			}
			System.out.println(str);
		} String str = br.readLine(); str br.readLine() br.readLine br if(str.equals("-")) break; str.equals("-") str.equals str "-" break; int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			} int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			} {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			} int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br str = str.substring(h, str.length()) + str.substring(0,h) str str.substring(h, str.length()) + str.substring(0,h) str.substring(h, str.length()) str.substring str h str.length() str.length str str.substring(0,h) str.substring str 0 h System.out.println(str) System.out.println System.out System System.out str String[] arsg arsg public class Main{
	public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		

		while(true){
			String str = br.readLine();
			if(str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			}
			System.out.println(str);
		}
	}
} public class Main{
	public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		

		while(true){
			String str = br.readLine();
			if(str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			}
			System.out.println(str);
		}
	}
} Main
import java.io.*;

public class Main{
	public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		

		while(true){
			String str = br.readLine();
			if(str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for(int i = 0;i<n;i++){
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0,h);
			}
			System.out.println(str);
		}
	}
}