import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		StringBuilder cardset;
		int shufflecount;
		int h;
		final char END = '-';

		Scanner stdIn = new Scanner(System.in);

		while(true) {
			cardset = new StringBuilder(stdIn.next());
			if(cardset.charAt(0) == END) {
				break;
			}
			shufflecount = stdIn.nextInt();

			for(int i = 0; i < shufflecount; i++) {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			}
			System.out.println(cardset);
		}
		stdIn.close();
	}
} import java.util.Scanner; Scanner java.util class Main {

	public static void main(String[] args) {

		StringBuilder cardset;
		int shufflecount;
		int h;
		final char END = '-';

		Scanner stdIn = new Scanner(System.in);

		while(true) {
			cardset = new StringBuilder(stdIn.next());
			if(cardset.charAt(0) == END) {
				break;
			}
			shufflecount = stdIn.nextInt();

			for(int i = 0; i < shufflecount; i++) {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			}
			System.out.println(cardset);
		}
		stdIn.close();
	}
} Main public static void main(String[] args) {

		StringBuilder cardset;
		int shufflecount;
		int h;
		final char END = '-';

		Scanner stdIn = new Scanner(System.in);

		while(true) {
			cardset = new StringBuilder(stdIn.next());
			if(cardset.charAt(0) == END) {
				break;
			}
			shufflecount = stdIn.nextInt();

			for(int i = 0; i < shufflecount; i++) {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			}
			System.out.println(cardset);
		}
		stdIn.close();
	} main {

		StringBuilder cardset;
		int shufflecount;
		int h;
		final char END = '-';

		Scanner stdIn = new Scanner(System.in);

		while(true) {
			cardset = new StringBuilder(stdIn.next());
			if(cardset.charAt(0) == END) {
				break;
			}
			shufflecount = stdIn.nextInt();

			for(int i = 0; i < shufflecount; i++) {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			}
			System.out.println(cardset);
		}
		stdIn.close();
	} StringBuilder cardset; cardset int shufflecount; shufflecount int h; h final char END = '-'; END '-' Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) while(true) {
			cardset = new StringBuilder(stdIn.next());
			if(cardset.charAt(0) == END) {
				break;
			}
			shufflecount = stdIn.nextInt();

			for(int i = 0; i < shufflecount; i++) {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			}
			System.out.println(cardset);
		} true {
			cardset = new StringBuilder(stdIn.next());
			if(cardset.charAt(0) == END) {
				break;
			}
			shufflecount = stdIn.nextInt();

			for(int i = 0; i < shufflecount; i++) {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			}
			System.out.println(cardset);
		} cardset = new StringBuilder(stdIn.next()) cardset new StringBuilder(stdIn.next()) if(cardset.charAt(0) == END) {
				break;
			} cardset.charAt(0) == END cardset.charAt(0) cardset.charAt cardset 0 END {
				break;
			} break; shufflecount = stdIn.nextInt() shufflecount stdIn.nextInt() stdIn.nextInt stdIn for(int i = 0; i < shufflecount; i++) {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			} int i = 0; int i = 0; i 0 i < shufflecount i shufflecount i++ i++ i {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			} {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			} h = stdIn.nextInt() h stdIn.nextInt() stdIn.nextInt stdIn String s = cardset.substring(0, h); s cardset.substring(0, h) cardset.substring cardset 0 h cardset.delete(0, h) cardset.delete cardset 0 h cardset.append(s) cardset.append cardset s System.out.println(cardset) System.out.println System.out System System.out cardset stdIn.close() stdIn.close stdIn String[] args args
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		StringBuilder cardset;
		int shufflecount;
		int h;
		final char END = '-';

		Scanner stdIn = new Scanner(System.in);

		while(true) {
			cardset = new StringBuilder(stdIn.next());
			if(cardset.charAt(0) == END) {
				break;
			}
			shufflecount = stdIn.nextInt();

			for(int i = 0; i < shufflecount; i++) {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			}
			System.out.println(cardset);
		}
		stdIn.close();
	}
}