import java.util.Scanner;

public class Main {

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

		while (true) {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		}
		scan.close();
		System.exit(0);
	}

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

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

		while (true) {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		}
		scan.close();
		System.exit(0);
	}

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

		while (true) {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		}
		scan.close();
		System.exit(0);
	} main {
		Scanner scan = new Scanner(System.in);

		while (true) {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		}
		scan.close();
		System.exit(0);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (true) {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		} true {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		} String cards = scan.next(); cards scan.next() scan.next scan if (cards.equals("-"))
				break; cards.equals("-") cards.equals cards "-" break; int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			} {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			} int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan cards = cards.substring(h, cards.length()).concat(cards.substring(0, h)) cards cards.substring(h, cards.length()).concat(cards.substring(0, h)) cards.substring(h, cards.length()).concat cards.substring(h, cards.length()) cards.substring cards h cards.length() cards.length cards cards.substring(0, h) cards.substring cards 0 h System.out.println(cards) System.out.println System.out System System.out cards scan.close() scan.close scan System.exit(0) System.exit System 0 String[] args args public class Main {

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

		while (true) {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		}
		scan.close();
		System.exit(0);
	}

} public class Main {

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

		while (true) {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		}
		scan.close();
		System.exit(0);
	}

} Main
import java.util.Scanner;

public class Main {

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

		while (true) {
			String cards = scan.next();
			if (cards.equals("-"))
				break;
			int n = scan.nextInt();
			for (int i = 0; i < n; i++) {
				int h = scan.nextInt();
				cards = cards.substring(h, cards.length()).concat(cards.substring(0, h));
			}
			System.out.println(cards);
		}
		scan.close();
		System.exit(0);
	}

}