import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String S = sc.next();
			if(S.equals("-")) break;
			int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			}
			
			System.out.println(S);
		}
	}
} import java.io.File; File java.io import java.io.IOException; IOException java.io import java.util.*; util.* java public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String S = sc.next();
			if(S.equals("-")) break;
			int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			}
			
			System.out.println(S);
		}
	}
} Main public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String S = sc.next();
			if(S.equals("-")) break;
			int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			}
			
			System.out.println(S);
		}
	} main {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String S = sc.next();
			if(S.equals("-")) break;
			int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			}
			
			System.out.println(S);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
			String S = sc.next();
			if(S.equals("-")) break;
			int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			}
			
			System.out.println(S);
		} true {
			String S = sc.next();
			if(S.equals("-")) break;
			int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			}
			
			System.out.println(S);
		} String S = sc.next(); S sc.next() sc.next sc if(S.equals("-")) break; S.equals("-") S.equals S "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			} {
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			} int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc String right = S.substring(h); right S.substring(h) S.substring S h String left = S.substring(0, h); left S.substring(0, h) S.substring S 0 h S = right + left S right + left right left System.out.println(S) System.out.println System.out System System.out S String[] args args public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String S = sc.next();
			if(S.equals("-")) break;
			int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			}
			
			System.out.println(S);
		}
	}
} public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String S = sc.next();
			if(S.equals("-")) break;
			int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			}
			
			System.out.println(S);
		}
	}
} Main
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String S = sc.next();
			if(S.equals("-")) break;
			int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				String right = S.substring(h);
				String left = S.substring(0, h);
				S = right + left;
			}
			
			System.out.println(S);
		}
	}
}
