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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		}
		if (br != null) {
			br.close();
			br = null;
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		}
		if (br != null) {
			br.close();
			br = null;
		}
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		}
		if (br != null) {
			br.close();
			br = null;
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		}
		if (br != null) {
			br.close();
			br = null;
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while (true) {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		} true {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		} String line = br.readLine(); line br.readLine() br.readLine br if ("-".equals(line))
				break; "-".equals(line) "-".equals "-" line break; String str = line; str line Integer cnt = Integer.parseInt(br.readLine()); cnt Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			} int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			} {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			} int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br str = str.substring(h) + str.substring(0, h) str str.substring(h) + str.substring(0, h) str.substring(h) str.substring str h str.substring(0, h) str.substring str 0 h System.out.println(str) System.out.println System.out System System.out str if (br != null) {
			br.close();
			br = null;
		} br != null br null {
			br.close();
			br = null;
		} br.close() br.close br br = null br null String[] args args public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		}
		if (br != null) {
			br.close();
			br = null;
		}
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		}
		if (br != null) {
			br.close();
			br = null;
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String line = br.readLine();
			if ("-".equals(line))
				break;

			String str = line;
			Integer cnt = Integer.parseInt(br.readLine());
			for (int i = 0; i < cnt; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h) + str.substring(0, h);
			}

			System.out.println(str);
		}
		if (br != null) {
			br.close();
			br = null;
		}
	}
}