import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) while (true) {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		} true {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		} String cards = in.readLine(); cards in.readLine() in.readLine in if (cards.equals("-")) {
				break;
			} cards.equals("-") cards.equals cards "-" {
				break;
			} break; int num = cards.length(); num cards.length() cards.length cards int time = Integer.parseInt(in.readLine()); time Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			} int i = 0; int i = 0; i 0 i < time i time i++ i++ i {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			} {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			} int shuffle = Integer.parseInt(in.readLine()); shuffle Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle) cards cards.substring(shuffle, num)
						+ cards.substring(0, shuffle) cards.substring(shuffle, num) cards.substring cards shuffle num cards.substring(0, shuffle) cards.substring cards 0 shuffle System.out.println(cards) System.out.println System.out System System.out cards String[] args args public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		}
	}
} public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String cards = in.readLine();
			if (cards.equals("-")) {
				break;
			}
			int num = cards.length();
			int time = Integer.parseInt(in.readLine());
			for (int i = 0; i < time; i++) {
				int shuffle = Integer.parseInt(in.readLine());

				cards = cards.substring(shuffle, num)
						+ cards.substring(0, shuffle);
			}
			System.out.println(cards);
		}
	}
}