import java.util.Scanner;

public class Main {

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

		while (true) {
			String line1 = sc.nextLine();
			if (line1.equals("-")) {
				break;
			}
			sb = new StringBuilder(line1);

			String line2 = sc.nextLine();
			int m = Integer.parseInt(line2);
			for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb);
		}

	}

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

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

		while (true) {
			String line1 = sc.nextLine();
			if (line1.equals("-")) {
				break;
			}
			sb = new StringBuilder(line1);

			String line2 = sc.nextLine();
			int m = Integer.parseInt(line2);
			for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb);
		}

	}

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

		while (true) {
			String line1 = sc.nextLine();
			if (line1.equals("-")) {
				break;
			}
			sb = new StringBuilder(line1);

			String line2 = sc.nextLine();
			int m = Integer.parseInt(line2);
			for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb);
		}

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

		while (true) {
			String line1 = sc.nextLine();
			if (line1.equals("-")) {
				break;
			}
			sb = new StringBuilder(line1);

			String line2 = sc.nextLine();
			int m = Integer.parseInt(line2);
			for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (true) {
			String line1 = sc.nextLine();
			if (line1.equals("-")) {
				break;
			}
			sb = new StringBuilder(line1);

			String line2 = sc.nextLine();
			int m = Integer.parseInt(line2);
			for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb);
		} true {
			String line1 = sc.nextLine();
			if (line1.equals("-")) {
				break;
			}
			sb = new StringBuilder(line1);

			String line2 = sc.nextLine();
			int m = Integer.parseInt(line2);
			for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb);
		} String line1 = sc.nextLine(); line1 sc.nextLine() sc.nextLine sc if (line1.equals("-")) {
				break;
			} line1.equals("-") line1.equals line1 "-" {
				break;
			} break; sb = new StringBuilder(line1) sb new StringBuilder(line1) String line2 = sc.nextLine(); line2 sc.nextLine() sc.nextLine sc int m = Integer.parseInt(line2); m Integer.parseInt(line2) Integer.parseInt Integer line2 for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			} {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			} String line3 = sc.nextLine(); line3 sc.nextLine() sc.nextLine sc int h = Integer.parseInt(line3); h Integer.parseInt(line3) Integer.parseInt Integer line3 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 System.out.println(sb) System.out.println System.out System System.out sb String[] args args public class Main {

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

		while (true) {
			String line1 = sc.nextLine();
			if (line1.equals("-")) {
				break;
			}
			sb = new StringBuilder(line1);

			String line2 = sc.nextLine();
			int m = Integer.parseInt(line2);
			for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb);
		}

	}

} public class Main {

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

		while (true) {
			String line1 = sc.nextLine();
			if (line1.equals("-")) {
				break;
			}
			sb = new StringBuilder(line1);

			String line2 = sc.nextLine();
			int m = Integer.parseInt(line2);
			for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb);
		}

	}

} Main
import java.util.Scanner;

public class Main {

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

		while (true) {
			String line1 = sc.nextLine();
			if (line1.equals("-")) {
				break;
			}
			sb = new StringBuilder(line1);

			String line2 = sc.nextLine();
			int m = Integer.parseInt(line2);
			for (int i = 0; i < m; i++) {
				String line3 = sc.nextLine();
				int h = Integer.parseInt(line3);
				sb.append(sb.substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb);
		}

	}

}