import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		}
		
	}
	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		}
		
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		}
		
	} run {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		}
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (true) {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		} true {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		} String card = scan.next(); card scan.next() scan.next scan if (card.equals("-")) break; card.equals("-") card.equals card "-" break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			} {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			} int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan String str = card.substring(0, h); str card.substring(0, h) card.substring card 0 h card = card.substring(h, card.length()) card card.substring(h, card.length()) card.substring card h card.length() card.length card card = card + str card card + str card str System.out.println(card) System.out.println System.out System System.out card public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		}
		
	}
	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		}
		
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		}
		
	}
	public static void main(String[] args) {
		new Main().run();
	}
}