import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			String data = sc.next();
			char[] card = data.toCharArray();

			if(data.equals("-")) break;

			char[] temp = new char[data.length()];

			int n = sc.nextInt();
		
			for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			}
			System.out.println(card);
		}

	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			String data = sc.next();
			char[] card = data.toCharArray();

			if(data.equals("-")) break;

			char[] temp = new char[data.length()];

			int n = sc.nextInt();
		
			for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			}
			System.out.println(card);
		}

	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			String data = sc.next();
			char[] card = data.toCharArray();

			if(data.equals("-")) break;

			char[] temp = new char[data.length()];

			int n = sc.nextInt();
		
			for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			}
			System.out.println(card);
		}

	} main {
		Scanner sc = new Scanner(System.in);

		while(true){
			String data = sc.next();
			char[] card = data.toCharArray();

			if(data.equals("-")) break;

			char[] temp = new char[data.length()];

			int n = sc.nextInt();
		
			for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			}
			System.out.println(card);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
			String data = sc.next();
			char[] card = data.toCharArray();

			if(data.equals("-")) break;

			char[] temp = new char[data.length()];

			int n = sc.nextInt();
		
			for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			}
			System.out.println(card);
		} true {
			String data = sc.next();
			char[] card = data.toCharArray();

			if(data.equals("-")) break;

			char[] temp = new char[data.length()];

			int n = sc.nextInt();
		
			for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			}
			System.out.println(card);
		} String data = sc.next(); data sc.next() sc.next sc char[] card = data.toCharArray(); card data.toCharArray() data.toCharArray data if(data.equals("-")) break; data.equals("-") data.equals data "-" break; char[] temp = new char[data.length()]; temp new char[data.length()] data.length() data.length data int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			} {
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			} int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				} int m = 0; int m = 0; m 0 m < num m num m++ m++ m {
					temp[data.length() - num + m] = card[m];
				} {
					temp[data.length() - num + m] = card[m];
				} temp[data.length() - num + m] = card[m] temp[data.length() - num + m] temp data.length() - num + m data.length() - num data.length() data.length data num m card[m] card m for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				} int m = num; int m = num; m num m < data.length() m data.length() data.length data m++ m++ m {
					temp[m - num] = card[m];
				} {
					temp[m - num] = card[m];
				} temp[m - num] = card[m] temp[m - num] temp m - num m num card[m] card m for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				} int m = 0; int m = 0; m 0 m < data.length() m data.length() data.length data m++ m++ m {
					card[m] = temp[m];
				} {
					card[m] = temp[m];
				} card[m] = temp[m] card[m] card m temp[m] temp m System.out.println(card) System.out.println System.out System System.out card String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			String data = sc.next();
			char[] card = data.toCharArray();

			if(data.equals("-")) break;

			char[] temp = new char[data.length()];

			int n = sc.nextInt();
		
			for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			}
			System.out.println(card);
		}

	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			String data = sc.next();
			char[] card = data.toCharArray();

			if(data.equals("-")) break;

			char[] temp = new char[data.length()];

			int n = sc.nextInt();
		
			for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			}
			System.out.println(card);
		}

	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			String data = sc.next();
			char[] card = data.toCharArray();

			if(data.equals("-")) break;

			char[] temp = new char[data.length()];

			int n = sc.nextInt();
		
			for(int i = 0;i < n;i++){
				int num = sc.nextInt();

				for(int m = 0;m < num;m++){
					temp[data.length() - num + m] = card[m];
				}
				
				for(int m = num;m < data.length();m++){
					temp[m - num] = card[m];
				}

				for(int m = 0;m < data.length();m++){
					card[m] = temp[m];
				}			
			}
			System.out.println(card);
		}

	}
}
