import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		}
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		}
	} main {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		} true {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		} String str = sc.next(); str sc.next() sc.next sc if (str.equals("-"))
				break; str.equals("-") str.equals str "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int sum = 0; sum 0 int[] x = new int[m]; x new int[m] m for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				x[i] = sc.nextInt();
				sum += x[i];
			} {
				x[i] = sc.nextInt();
				sum += x[i];
			} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc sum += x[i] sum x[i] x i int a = sum % str.length(); a sum % str.length() sum str.length() str.length str System.out.printf("%s%s\n", str.substring(a), str.substring(0, a)) System.out.printf System.out System System.out "%s%s\n" str.substring(a) str.substring str a str.substring(0, a) str.substring str 0 a String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		}
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		}
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String str = sc.next();
			if (str.equals("-"))
				break;
			int m = sc.nextInt();
			int sum = 0;
			int[] x = new int[m];
			for (int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
				sum += x[i];
			}
			int a = sum % str.length();
			System.out.printf("%s%s\n", str.substring(a), str.substring(0, a));
		}
	}

}
