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

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		String str2 = "";

		String num = "";

		int num2;

		StringBuilder builder = new StringBuilder();

		while (!(str.equals("-"))) {

			num = br.readLine();


			for (int i = 0; i < Integer.parseInt(num); i++) {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			}
			str2 += str + "\n";
			str = br.readLine();

		}

		System.out.print(str2);
	}

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

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		String str2 = "";

		String num = "";

		int num2;

		StringBuilder builder = new StringBuilder();

		while (!(str.equals("-"))) {

			num = br.readLine();


			for (int i = 0; i < Integer.parseInt(num); i++) {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			}
			str2 += str + "\n";
			str = br.readLine();

		}

		System.out.print(str2);
	}

} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		String str2 = "";

		String num = "";

		int num2;

		StringBuilder builder = new StringBuilder();

		while (!(str.equals("-"))) {

			num = br.readLine();


			for (int i = 0; i < Integer.parseInt(num); i++) {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			}
			str2 += str + "\n";
			str = br.readLine();

		}

		System.out.print(str2);
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		String str2 = "";

		String num = "";

		int num2;

		StringBuilder builder = new StringBuilder();

		while (!(str.equals("-"))) {

			num = br.readLine();


			for (int i = 0; i < Integer.parseInt(num); i++) {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			}
			str2 += str + "\n";
			str = br.readLine();

		}

		System.out.print(str2);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br String str2 = ""; str2 "" String num = ""; num "" int num2; num2 StringBuilder builder = new StringBuilder(); builder new StringBuilder() while (!(str.equals("-"))) {

			num = br.readLine();


			for (int i = 0; i < Integer.parseInt(num); i++) {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			}
			str2 += str + "\n";
			str = br.readLine();

		} !(str.equals("-")) (str.equals("-")) str.equals str "-" {

			num = br.readLine();


			for (int i = 0; i < Integer.parseInt(num); i++) {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			}
			str2 += str + "\n";
			str = br.readLine();

		} num = br.readLine() num br.readLine() br.readLine br for (int i = 0; i < Integer.parseInt(num); i++) {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			} int i = 0; int i = 0; i 0 i < Integer.parseInt(num) i Integer.parseInt(num) Integer.parseInt Integer num i++ i++ i {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			} {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			} num2 = Integer.parseInt(br.readLine()) num2 Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br builder.append(str.substring(num2, str.length())) builder.append builder str.substring(num2, str.length()) str.substring str num2 str.length() str.length str builder.append(str.substring(0, num2)) builder.append builder str.substring(0, num2) str.substring str 0 num2 str = builder.toString() str builder.toString() builder.toString builder builder.setLength(0) builder.setLength builder 0 str2 += str + "\n" str2 str + "\n" str "\n" str = br.readLine() str br.readLine() br.readLine br System.out.print(str2) System.out.print System.out System System.out str2 String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		String str2 = "";

		String num = "";

		int num2;

		StringBuilder builder = new StringBuilder();

		while (!(str.equals("-"))) {

			num = br.readLine();


			for (int i = 0; i < Integer.parseInt(num); i++) {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			}
			str2 += str + "\n";
			str = br.readLine();

		}

		System.out.print(str2);
	}

}