import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			String str = s.next();
			if (str.equals("-")) return;
			int n = Integer.parseInt(s.next());
			for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			String str = s.next();
			if (str.equals("-")) return;
			int n = Integer.parseInt(s.next());
			for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		}
	}
} Main public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			String str = s.next();
			if (str.equals("-")) return;
			int n = Integer.parseInt(s.next());
			for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		}
	} main {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			String str = s.next();
			if (str.equals("-")) return;
			int n = Integer.parseInt(s.next());
			for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		}
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) while (s.hasNext()) {
			String str = s.next();
			if (str.equals("-")) return;
			int n = Integer.parseInt(s.next());
			for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		} s.hasNext() s.hasNext s {
			String str = s.next();
			if (str.equals("-")) return;
			int n = Integer.parseInt(s.next());
			for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		} String str = s.next(); str s.next() s.next s if (str.equals("-")) return; str.equals("-") str.equals str "-" return; int n = Integer.parseInt(s.next()); n Integer.parseInt(s.next()) Integer.parseInt Integer s.next() s.next s for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			} int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			} {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			} int h = Integer.parseInt(s.next()); h Integer.parseInt(s.next()) Integer.parseInt Integer s.next() s.next s str = str.substring(h, str.length()) + str.substring(0, h) str str.substring(h, str.length()) + str.substring(0, h) str.substring(h, str.length()) str.substring str h str.length() str.length str str.substring(0, h) str.substring str 0 h System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			String str = s.next();
			if (str.equals("-")) return;
			int n = Integer.parseInt(s.next());
			for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			String str = s.next();
			if (str.equals("-")) return;
			int n = Integer.parseInt(s.next());
			for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			String str = s.next();
			if (str.equals("-")) return;
			int n = Integer.parseInt(s.next());
			for (int i = 0; i < n; ++i) {
				int h = Integer.parseInt(s.next());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		}
	}
}