import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		}

	}

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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		}

	}

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

		Scanner scan = new Scanner(System.in);

		for(;;){

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		}

	} main {

		Scanner scan = new Scanner(System.in);

		for(;;){

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		}

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(;;){

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		} ; {

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		} {

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		} String str = scan.next(); str scan.next() scan.next scan StringBuilder card = new StringBuilder(str); card new StringBuilder(str) if(str.equals("-"))
				break; str.equals("-") str.equals str "-" break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan int[] shuffle = new int[m]; shuffle new int[m] m for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			} {
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			} shuffle[i] = scan.nextInt() shuffle[i] shuffle i scan.nextInt() scan.nextInt scan card.append(card.substring(0,shuffle[i])) card.append card card.substring(0,shuffle[i]) card.substring card 0 shuffle[i] shuffle i card.delete(0, shuffle[i]) card.delete card 0 shuffle[i] shuffle i 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 scan = new Scanner(System.in);

		for(;;){

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		}

	}

} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		}

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			String str = scan.next();
			StringBuilder card = new StringBuilder(str);

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

			int m = scan.nextInt();
			int[] shuffle = new int[m];

			for(int i = 0; i < m; i++){
				shuffle[i] = scan.nextInt();
				card.append(card.substring(0,shuffle[i]));
				card.delete(0, shuffle[i]);
			}
			System.out.println(card);

		}

	}

}