import java.util.Scanner;

public class Main {

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



		do {

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		}while(true);

		sc.close();

	}

	private static char[] shuffle(char[] cards, int h) {
		char[] cards_tmp1 = new char[h];
		char[] cards_tmp2 = new char[cards.length - h];
		char[] cards_ex = new char[cards.length];

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_tmp1[i] = cards[i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_tmp2[i] = cards[h + i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_ex[i] = cards_tmp2[i];
		}

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		}

	    return cards_ex;

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

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



		do {

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		}while(true);

		sc.close();

	}

	private static char[] shuffle(char[] cards, int h) {
		char[] cards_tmp1 = new char[h];
		char[] cards_tmp2 = new char[cards.length - h];
		char[] cards_ex = new char[cards.length];

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_tmp1[i] = cards[i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_tmp2[i] = cards[h + i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_ex[i] = cards_tmp2[i];
		}

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		}

	    return cards_ex;

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



		do {

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		}while(true);

		sc.close();

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



		do {

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		}while(true);

		sc.close();

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

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		}while(true); true {

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		} String str = sc.nextLine() ; str sc.nextLine() sc.nextLine sc if(str.equals("-")) {
				break;
			} str.equals("-") str.equals str "-" {
				break;
			} break; char[] cards = str.toCharArray(); cards str.toCharArray() str.toCharArray str int m = Integer.parseInt(sc.nextLine()); m Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			} {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			} int h = Integer.parseInt(sc.nextLine()); h Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc cards = shuffle(cards, h) cards shuffle(cards, h) shuffle cards h for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			} int j = 0; int j = 0; j 0 j < cards.length j cards.length cards cards.length j++ j++ j {
				System.out.print(cards[j]);
			} {
				System.out.print(cards[j]);
			} System.out.print(cards[j]) System.out.print System.out System System.out cards[j] cards j System.out.println() System.out.println System.out System System.out sc.close() sc.close sc String[] args args private static char[] shuffle(char[] cards, int h) {
		char[] cards_tmp1 = new char[h];
		char[] cards_tmp2 = new char[cards.length - h];
		char[] cards_ex = new char[cards.length];

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_tmp1[i] = cards[i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_tmp2[i] = cards[h + i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_ex[i] = cards_tmp2[i];
		}

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		}

	    return cards_ex;

	} shuffle {
		char[] cards_tmp1 = new char[h];
		char[] cards_tmp2 = new char[cards.length - h];
		char[] cards_ex = new char[cards.length];

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_tmp1[i] = cards[i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_tmp2[i] = cards[h + i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_ex[i] = cards_tmp2[i];
		}

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		}

	    return cards_ex;

	} char[] cards_tmp1 = new char[h]; cards_tmp1 new char[h] h char[] cards_tmp2 = new char[cards.length - h]; cards_tmp2 new char[cards.length - h] cards.length - h cards.length cards cards.length h char[] cards_ex = new char[cards.length]; cards_ex new char[cards.length] cards.length cards cards.length for (int i = 0; i < cards_tmp1.length; i++) {
			cards_tmp1[i] = cards[i];
		} int i = 0; int i = 0; i 0 i < cards_tmp1.length i cards_tmp1.length cards_tmp1 cards_tmp1.length i++ i++ i {
			cards_tmp1[i] = cards[i];
		} {
			cards_tmp1[i] = cards[i];
		} cards_tmp1[i] = cards[i] cards_tmp1[i] cards_tmp1 i cards[i] cards i for (int i = 0; i < cards_tmp2.length; i++) {
			cards_tmp2[i] = cards[h + i];
		} int i = 0; int i = 0; i 0 i < cards_tmp2.length i cards_tmp2.length cards_tmp2 cards_tmp2.length i++ i++ i {
			cards_tmp2[i] = cards[h + i];
		} {
			cards_tmp2[i] = cards[h + i];
		} cards_tmp2[i] = cards[h + i] cards_tmp2[i] cards_tmp2 i cards[h + i] cards h + i h i for (int i = 0; i < cards_tmp2.length; i++) {
			cards_ex[i] = cards_tmp2[i];
		} int i = 0; int i = 0; i 0 i < cards_tmp2.length i cards_tmp2.length cards_tmp2 cards_tmp2.length i++ i++ i {
			cards_ex[i] = cards_tmp2[i];
		} {
			cards_ex[i] = cards_tmp2[i];
		} cards_ex[i] = cards_tmp2[i] cards_ex[i] cards_ex i cards_tmp2[i] cards_tmp2 i for (int i = 0; i < cards_tmp1.length; i++) {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		} int i = 0; int i = 0; i 0 i < cards_tmp1.length i cards_tmp1.length cards_tmp1 cards_tmp1.length i++ i++ i {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		} {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		} cards_ex[cards.length - h + i] = cards_tmp1[i] cards_ex[cards.length - h + i] cards_ex cards.length - h + i cards.length - h cards.length cards cards.length h i cards_tmp1[i] cards_tmp1 i return cards_ex; cards_ex char[] cards cards int h h public class Main {

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



		do {

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		}while(true);

		sc.close();

	}

	private static char[] shuffle(char[] cards, int h) {
		char[] cards_tmp1 = new char[h];
		char[] cards_tmp2 = new char[cards.length - h];
		char[] cards_ex = new char[cards.length];

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_tmp1[i] = cards[i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_tmp2[i] = cards[h + i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_ex[i] = cards_tmp2[i];
		}

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		}

	    return cards_ex;

	}
} public class Main {

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



		do {

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		}while(true);

		sc.close();

	}

	private static char[] shuffle(char[] cards, int h) {
		char[] cards_tmp1 = new char[h];
		char[] cards_tmp2 = new char[cards.length - h];
		char[] cards_ex = new char[cards.length];

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_tmp1[i] = cards[i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_tmp2[i] = cards[h + i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_ex[i] = cards_tmp2[i];
		}

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		}

	    return cards_ex;

	}
} Main
import java.util.Scanner;

public class Main {

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



		do {

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		}while(true);

		sc.close();

	}

	private static char[] shuffle(char[] cards, int h) {
		char[] cards_tmp1 = new char[h];
		char[] cards_tmp2 = new char[cards.length - h];
		char[] cards_ex = new char[cards.length];

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_tmp1[i] = cards[i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_tmp2[i] = cards[h + i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_ex[i] = cards_tmp2[i];
		}

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		}

	    return cards_ex;

	}
}

