import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		}
	}
}

		

	 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		}
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		}
	} main {
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(;;){
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		} ; {
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		} {
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		} String x = scan.next(); x scan.next() scan.next scan if(x.equals("-"))
			break; x.equals("-") x.equals x "-" break; String sx[] = x.split(""); sx x.split("") x.split x "" String[] a; a a = new String[10000] a new String[10000] 10000 int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan int i i t t c; c for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		} i = 0; i = 0 i 0 i < m i m i++ i++ i {
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		} {
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		} c = 0 c 0 int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			} t = h; t = h t h t < x.length() t x.length() x.length x t++ t++ t {
				a[c++] = sx[t];
			} {
				a[c++] = sx[t];
			} a[c++] = sx[t] a[c++] a c++ c sx[t] sx t for(t = 0; t < h; t++){
				a[c++] = sx[t];
			} t = 0; t = 0 t 0 t < h t h t++ t++ t {
				a[c++] = sx[t];
			} {
				a[c++] = sx[t];
			} a[c++] = sx[t] a[c++] a c++ c sx[t] sx t for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			} t = 0; t = 0 t 0 t < x.length() t x.length() x.length x t++ t++ t {
				sx[t] = a[t];
			} {
				sx[t] = a[t];
			} sx[t] = a[t] sx[t] sx t a[t] a t for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		} t = 0; t = 0 t 0 t < x.length() t x.length() x.length x t++ t++ t {
			System.out.print(sx[t]);
		} {
			System.out.print(sx[t]);
		} System.out.print(sx[t]) System.out.print System.out System System.out sx[t] sx t System.out.println() System.out.println System.out System System.out String[] args args public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		}
	}
} public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		}
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(;;){
		String x = scan.next();
		if(x.equals("-"))
			break;
		String sx[] = x.split("");
		String[] a;
		a = new String[10000];
		int m = scan.nextInt();
		int i,t,c;
		for(i = 0; i < m; i++){
			c = 0;
			int h = scan.nextInt();
			for(t = h; t < x.length(); t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < h; t++){
				a[c++] = sx[t];
			}
			for(t = 0; t < x.length(); t++){
				sx[t] = a[t];
			}
		}
		for(t = 0; t < x.length(); t++){
			System.out.print(sx[t]);
		}
		System.out.println();
		}
	}
}

		

	