import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		}

		for (int j = 0; j < list.size(); j++) {

			System.out.println(list.get(j));

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

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

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		}

		for (int j = 0; j < list.size(); j++) {

			System.out.println(list.get(j));

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

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

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		}

		for (int j = 0; j < list.size(); j++) {

			System.out.println(list.get(j));

		}

		close();

	} main {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		}

		for (int j = 0; j < list.size(); j++) {

			System.out.println(list.get(j));

		}

		close();

	} ArrayList<String> list = new ArrayList<String>(); list new ArrayList<String>() while (true) {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		} true {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		} StringBuilder sb = new StringBuilder(); sb new StringBuilder() String input = input(); input input() input if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			} input.equals("-") input.equals input "-" {

				break;

			} break; {

				sb.append(input);

			} sb.append(input) sb.append sb input int n = Integer.parseInt(input()); n Integer.parseInt(input()) Integer.parseInt Integer input() input for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			} {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			} int h = Integer.parseInt(input()); h Integer.parseInt(input()) Integer.parseInt Integer input() input sb.append(sb.substring(0, h)) sb.append sb sb.substring(0, h) sb.substring sb 0 h sb.delete(0, h) sb.delete sb 0 h list.add(sb.toString()) list.add list sb.toString() sb.toString sb for (int j = 0; j < list.size(); j++) {

			System.out.println(list.get(j));

		} int j = 0; int j = 0; j 0 j < list.size() j list.size() list.size list j++ j++ j {

			System.out.println(list.get(j));

		} {

			System.out.println(list.get(j));

		} System.out.println(list.get(j)) System.out.println System.out System System.out list.get(j) list.get list j close() close String[] args args public static String input() {

		return scanner.nextLine();

	} input {

		return scanner.nextLine();

	} return scanner.nextLine(); scanner.nextLine() scanner.nextLine scanner public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	} close {

		if (scanner != null) {

			scanner.close();

		}
	} if (scanner != null) {

			scanner.close();

		} scanner != null scanner null {

			scanner.close();

		} scanner.close() scanner.close scanner public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		}

		for (int j = 0; j < list.size(); j++) {

			System.out.println(list.get(j));

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		}

		for (int j = 0; j < list.size(); j++) {

			System.out.println(list.get(j));

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			StringBuilder sb = new StringBuilder();
			String input = input();

			if (input.equals("-")) {

				break;

			} else {

				sb.append(input);

			}

			int n = Integer.parseInt(input());

			for (int i = 0; i < n; i++) {

				int h = Integer.parseInt(input());

				sb.append(sb.substring(0, h));
				sb.delete(0, h);

			}

			list.add(sb.toString());

		}

		for (int j = 0; j < list.size(); j++) {

			System.out.println(list.get(j));

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}