import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		}
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (sc.hasNext()) {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		} sc.hasNext() sc.hasNext sc {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		} String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc if (str.equals("-"))
				break; str.equals("-") str.equals str "-" break; int m = Integer.parseInt(sc.nextLine()); m Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			} {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			} String nextStr = sc.nextLine(); nextStr sc.nextLine() sc.nextLine sc str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString() str new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString() new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr))) new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr))) new StringBuilder()
						.append new StringBuilder() str.substring(Integer.parseInt(nextStr)) str.substring str Integer.parseInt(nextStr) Integer.parseInt Integer nextStr str.substring(0, Integer.parseInt(nextStr)) str.substring str 0 Integer.parseInt(nextStr) Integer.parseInt Integer nextStr System.out.println(str) System.out.println System.out System System.out str sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		}
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		}
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		}
		sc.close();
	}
}