import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		}
		System.out.print(sb);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		}
		System.out.print(sb);
	}
} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		}
		System.out.print(sb);
	} main {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		}
		System.out.print(sb);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (true) {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		} true {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		} String cards = scan.next(); cards scan.next() scan.next scan if (cards.equals("-")) {
				break;
			} cards.equals("-") cards.equals cards "-" {
				break;
			} break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			} {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			} int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan cards = (cards.substring(h) + cards.substring(0, h)) cards (cards.substring(h) + cards.substring(0, h)) cards.substring(h) cards.substring cards h cards.substring(0, h) cards.substring cards 0 h sb.append(cards + "\n") sb.append sb cards + "\n" cards "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		}
		System.out.print(sb);
	}
} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		}
		System.out.print(sb);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		}
		System.out.print(sb);
	}
}