import java.util.Scanner;

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

		for (int j = 0; j < 10; j++) {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		}
	}

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

		for (int j = 0; j < 10; j++) {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		}
	}

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

		for (int j = 0; j < 10; j++) {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

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

		for (int j = 0; j < 10; j++) {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) for (int j = 0; j < 10; j++) {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		} int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		} {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		} String line = sc.next(); line sc.next() sc.next sc if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			} line.charAt(0) == '-' line.charAt(0) line.charAt line 0 '-' {
				System.exit(0);
			} System.exit(0) System.exit System 0 if (line.length() > 200) {
				System.exit(0);
			} line.length() > 200 line.length() line.length line 200 {
				System.exit(0);
			} System.exit(0) System.exit System 0 int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc if (m > 100 || m < 1) {
				System.exit(0);
			} m > 100 || m < 1 m > 100 m 100 m < 1 m 1 {
				System.exit(0);
			} System.exit(0) System.exit System 0 for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			} {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			} int hi = sc.nextInt(); hi sc.nextInt() sc.nextInt sc if (hi > line.length() || hi < 1) {
					System.exit(0);
				} hi > line.length() || hi < 1 hi > line.length() hi line.length() line.length line hi < 1 hi 1 {
					System.exit(0);
				} System.exit(0) System.exit System 0 String line1 = line.substring(0, hi); line1 line.substring(0, hi) line.substring line 0 hi String line2 = line.substring(hi); line2 line.substring(hi) line.substring line hi line = line2 + line1 line line2 + line1 line2 line1 System.out.println(line) System.out.println System.out System System.out line String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		for (int j = 0; j < 10; j++) {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		}
	}

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

		for (int j = 0; j < 10; j++) {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		}
	}

} Main
import java.util.Scanner;

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

		for (int j = 0; j < 10; j++) {
			String line = sc.next();
			if (line.charAt(0) == '-') {
				System.exit(0);
			} else if (line.length() > 200) {
				System.exit(0);
			}

			int m = sc.nextInt();
			if (m > 100 || m < 1) {
				System.exit(0);
			}

			for (int i = 0; i < m; i++) {
				int hi = sc.nextInt();
				if (hi > line.length() || hi < 1) {
					System.exit(0);
				}

				String line1 = line.substring(0, hi);
				String line2 = line.substring(hi);

				line = line2 + line1;

			}

			System.out.println(line);

		}
	}

}

