import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		int n = sc.nextInt();
		int h = sc.nextInt();
		String str2 = null;

		while (true) {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		}

	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		int n = sc.nextInt();
		int h = sc.nextInt();
		String str2 = null;

		while (true) {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		}

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		int n = sc.nextInt();
		int h = sc.nextInt();
		String str2 = null;

		while (true) {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		}

	} main {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		int n = sc.nextInt();
		int h = sc.nextInt();
		String str2 = null;

		while (true) {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc String str2 = null; str2 null while (true) {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		} true {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		} for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			} {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			} str2 = str.substring(0, h) str2 str.substring(0, h) str.substring str 0 h str = str.substring(h, str.length()) str str.substring(h, str.length()) str.substring str h str.length() str.length str str = str + str2 str str + str2 str str2 if (i != n - 1) {
					h = sc.nextInt();
				} i != n - 1 i n - 1 n 1 {
					h = sc.nextInt();
				} h = sc.nextInt() h sc.nextInt() sc.nextInt sc System.out.println(str) System.out.println System.out System System.out str str = sc.nextLine() str sc.nextLine() sc.nextLine sc str = sc.nextLine() str sc.nextLine() sc.nextLine sc if (str.equals("-")) {
				break;
			} str.equals("-") str.equals str "-" {
				break;
			} break; n = sc.nextInt() n sc.nextInt() sc.nextInt sc h = sc.nextInt() h sc.nextInt() sc.nextInt sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		int n = sc.nextInt();
		int h = sc.nextInt();
		String str2 = null;

		while (true) {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		}

	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		int n = sc.nextInt();
		int h = sc.nextInt();
		String str2 = null;

		while (true) {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		}

	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		int n = sc.nextInt();
		int h = sc.nextInt();
		String str2 = null;

		while (true) {

			for (int i = 0; i < n; i++) {
				str2 = str.substring(0, h);
				str = str.substring(h, str.length());
				str = str + str2;
				if (i != n - 1) {
					h = sc.nextInt();
				}
			}

			System.out.println(str);

			str = sc.nextLine();
			str = sc.nextLine();

			if (str.equals("-")) {
				break;
			}
			n = sc.nextInt();
			h = sc.nextInt();

		}

	}
}