
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.next();
			if (a.equals("-")) {
				break;
			}
			int b = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			}
			String c = a + a;
			System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length()));
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.next();
			if (a.equals("-")) {
				break;
			}
			int b = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			}
			String c = a + a;
			System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length()));
		}
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.next();
			if (a.equals("-")) {
				break;
			}
			int b = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			}
			String c = a + a;
			System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length()));
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.next();
			if (a.equals("-")) {
				break;
			}
			int b = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			}
			String c = a + a;
			System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length()));
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while (true) {
			String a = scanner.next();
			if (a.equals("-")) {
				break;
			}
			int b = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			}
			String c = a + a;
			System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length()));
		} true {
			String a = scanner.next();
			if (a.equals("-")) {
				break;
			}
			int b = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			}
			String c = a + a;
			System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length()));
		} String a = scanner.next(); a scanner.next() scanner.next scanner if (a.equals("-")) {
				break;
			} a.equals("-") a.equals a "-" {
				break;
			} break; int b = scanner.nextInt(); b scanner.nextInt() scanner.nextInt scanner int sum = 0; sum 0 for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			} int i = 0; int i = 0; i 0 i < b i b i++ i++ i {
				sum += scanner.nextInt();
			} {
				sum += scanner.nextInt();
			} sum += scanner.nextInt() sum scanner.nextInt() scanner.nextInt scanner String c = a + a; c a + a a a System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length())) System.out.println System.out System System.out c.substring(sum % a.length(), sum
					% a.length() + a.length()) c.substring c sum % a.length() sum a.length() a.length a sum
					% a.length() + a.length() sum
					% a.length() sum a.length() a.length a a.length() a.length a String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.next();
			if (a.equals("-")) {
				break;
			}
			int b = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			}
			String c = a + a;
			System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length()));
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.next();
			if (a.equals("-")) {
				break;
			}
			int b = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			}
			String c = a + a;
			System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length()));
		}
	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.next();
			if (a.equals("-")) {
				break;
			}
			int b = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < b; i++) {
				sum += scanner.nextInt();
			}
			String c = a + a;
			System.out.println(c.substring(sum % a.length(), sum
					% a.length() + a.length()));
		}
	}
}