import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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


		StringBuilder sb = new StringBuilder();
		while (true) {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		}

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


		StringBuilder sb = new StringBuilder();
		while (true) {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		}

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


		StringBuilder sb = new StringBuilder();
		while (true) {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		}

		System.out.print(sb.toString());
	} main {
		Scanner sc = new Scanner(System.in);


		StringBuilder sb = new StringBuilder();
		while (true) {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		}

		System.out.print(sb.toString());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (true) {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		} true {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		} String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc if ("-".equals(line)) {
				break;
			} "-".equals(line) "-".equals "-" line {
				break;
			} break; ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) ); cards new ArrayList<String>( Arrays.asList(line.split("")) ) int shuffleCount = Integer.parseInt(sc.nextLine()); shuffleCount Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

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

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			} {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			} int maisu = Integer.parseInt(sc.nextLine()); maisu Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				} int j = 0; int j = 0; j 0 j < maisu j maisu j++ j++ j {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				} {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				} String card = cards.remove(0); card cards.remove(0) cards.remove cards 0 cards.add(card) cards.add cards card sb.append(String.join("", cards)) sb.append sb String.join("", cards) String.join String "" cards sb.append("\n") sb.append sb "\n" System.out.print(sb.toString()) System.out.print System.out System System.out sb.toString() sb.toString sb String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);


		StringBuilder sb = new StringBuilder();
		while (true) {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		}

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


		StringBuilder sb = new StringBuilder();
		while (true) {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		}

		System.out.print(sb.toString());
	}
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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


		StringBuilder sb = new StringBuilder();
		while (true) {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

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


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		}

		System.out.print(sb.toString());
	}
}
