import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String t;
		int i, cnt, idx;
		while(true){
			t = sc.next();
			if(t.equals("-")) break;
			cnt = sc.nextInt();
			for(i=0; i<cnt; i++){
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			}
			System.out.println(t);
		}
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String t;
		int i, cnt, idx;
		while(true){
			t = sc.next();
			if(t.equals("-")) break;
			cnt = sc.nextInt();
			for(i=0; i<cnt; i++){
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			}
			System.out.println(t);
		}
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String t;
		int i, cnt, idx;
		while(true){
			t = sc.next();
			if(t.equals("-")) break;
			cnt = sc.nextInt();
			for(i=0; i<cnt; i++){
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			}
			System.out.println(t);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String t;
		int i, cnt, idx;
		while(true){
			t = sc.next();
			if(t.equals("-")) break;
			cnt = sc.nextInt();
			for(i=0; i<cnt; i++){
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			}
			System.out.println(t);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String t; t int i i cnt cnt idx; idx while(true){
			t = sc.next();
			if(t.equals("-")) break;
			cnt = sc.nextInt();
			for(i=0; i<cnt; i++){
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			}
			System.out.println(t);
		} true {
			t = sc.next();
			if(t.equals("-")) break;
			cnt = sc.nextInt();
			for(i=0; i<cnt; i++){
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			}
			System.out.println(t);
		} t = sc.next() t sc.next() sc.next sc if(t.equals("-")) break; t.equals("-") t.equals t "-" break; cnt = sc.nextInt() cnt sc.nextInt() sc.nextInt sc for(i=0; i<cnt; i++){
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			} i=0; i=0 i 0 i<cnt i cnt i++ i++ i {
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			} {
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			} idx = sc.nextInt() idx sc.nextInt() sc.nextInt sc t = t.substring(idx).concat(t.substring(0, idx)) t t.substring(idx).concat(t.substring(0, idx)) t.substring(idx).concat t.substring(idx) t.substring t idx t.substring(0, idx) t.substring t 0 idx System.out.println(t) System.out.println System.out System System.out t String[] args args
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String t;
		int i, cnt, idx;
		while(true){
			t = sc.next();
			if(t.equals("-")) break;
			cnt = sc.nextInt();
			for(i=0; i<cnt; i++){
				idx = sc.nextInt();
				t = t.substring(idx).concat(t.substring(0, idx));
			}
			System.out.println(t);
		}
	}
}