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