

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while(true){

			StringBuilder str = new StringBuilder(in.next());

			if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			}

			System.out.println(str.toString());



		}





	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while(true){

			StringBuilder str = new StringBuilder(in.next());

			if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			}

			System.out.println(str.toString());



		}





	}

} Main public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while(true){

			StringBuilder str = new StringBuilder(in.next());

			if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			}

			System.out.println(str.toString());



		}





	} main {

		Scanner in = new Scanner(System.in);

		while(true){

			StringBuilder str = new StringBuilder(in.next());

			if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			}

			System.out.println(str.toString());



		}





	} Scanner in = new Scanner(System.in); in new Scanner(System.in) while(true){

			StringBuilder str = new StringBuilder(in.next());

			if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			}

			System.out.println(str.toString());



		} true {

			StringBuilder str = new StringBuilder(in.next());

			if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			}

			System.out.println(str.toString());



		} StringBuilder str = new StringBuilder(in.next()); str new StringBuilder(in.next()) if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			} str.substring(0).equals("-") str.substring(0).equals str.substring(0) str.substring str 0 "-" {

				break;

			} break; {

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			} int shuffle_num = in.nextInt(); shuffle_num in.nextInt() in.nextInt in for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				} int i = 0; int i = 0; i 0 i < shuffle_num i shuffle_num i++ i++ i {

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				} {

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				} int card_num = in.nextInt(); card_num in.nextInt() in.nextInt in String shuffle_word = str.substring(0, card_num); shuffle_word str.substring(0, card_num) str.substring str 0 card_num str.delete(0, card_num) str.delete str 0 card_num str.append(shuffle_word) str.append str shuffle_word System.out.println(str.toString()) System.out.println System.out System System.out str.toString() str.toString str String[] args args public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while(true){

			StringBuilder str = new StringBuilder(in.next());

			if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			}

			System.out.println(str.toString());



		}





	}

} public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while(true){

			StringBuilder str = new StringBuilder(in.next());

			if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			}

			System.out.println(str.toString());



		}





	}

} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while(true){

			StringBuilder str = new StringBuilder(in.next());

			if(str.substring(0).equals("-")){

				break;

			}else{

			int shuffle_num = in.nextInt();

				for(int i = 0; i < shuffle_num; i++){

					int card_num = in.nextInt();

					String shuffle_word = str.substring(0, card_num);

					str.delete(0, card_num);

					str.append(shuffle_word);

				}
			}

			System.out.println(str.toString());



		}





	}

}