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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuffer sb1 = null;
		StringBuffer sb2 = new StringBuffer();
		String cards;
		while (!(cards = input.readLine()).equals("-")) {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		}
		System.out.print(sb2);

	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuffer sb1 = null;
		StringBuffer sb2 = new StringBuffer();
		String cards;
		while (!(cards = input.readLine()).equals("-")) {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		}
		System.out.print(sb2);

	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuffer sb1 = null;
		StringBuffer sb2 = new StringBuffer();
		String cards;
		while (!(cards = input.readLine()).equals("-")) {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		}
		System.out.print(sb2);

	} main {
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuffer sb1 = null;
		StringBuffer sb2 = new StringBuffer();
		String cards;
		while (!(cards = input.readLine()).equals("-")) {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		}
		System.out.print(sb2);

	} BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in)); input new BufferedReader(new InputStreamReader(
				System.in)) StringBuffer sb1 = null; sb1 null StringBuffer sb2 = new StringBuffer(); sb2 new StringBuffer() String cards; cards while (!(cards = input.readLine()).equals("-")) {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		} !(cards = input.readLine()).equals("-") (cards = input.readLine()).equals("-") (cards = input.readLine()).equals (cards = input.readLine()) cards input.readLine() input.readLine input "-" {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		} sb1 = new StringBuffer(cards) sb1 new StringBuffer(cards) int shuffle = Integer.parseInt(input.readLine()); shuffle Integer.parseInt(input.readLine()) Integer.parseInt Integer input.readLine() input.readLine input int i = 0; i 0 while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			} i != shuffle i shuffle {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			} i++ i int n = Integer.parseInt(input.readLine()); n Integer.parseInt(input.readLine()) Integer.parseInt Integer input.readLine() input.readLine input String str = sb1.substring(0, n); str sb1.substring(0, n) sb1.substring sb1 0 n sb1.delete(0, n) sb1.delete sb1 0 n sb1.append(str) sb1.append sb1 str sb2.append(sb1 + "\n") sb2.append sb2 sb1 + "\n" sb1 "\n" System.out.print(sb2) System.out.print System.out System System.out sb2 String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuffer sb1 = null;
		StringBuffer sb2 = new StringBuffer();
		String cards;
		while (!(cards = input.readLine()).equals("-")) {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		}
		System.out.print(sb2);

	}

} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuffer sb1 = null;
		StringBuffer sb2 = new StringBuffer();
		String cards;
		while (!(cards = input.readLine()).equals("-")) {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		}
		System.out.print(sb2);

	}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuffer sb1 = null;
		StringBuffer sb2 = new StringBuffer();
		String cards;
		while (!(cards = input.readLine()).equals("-")) {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		}
		System.out.print(sb2);

	}

}