import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i, j, k, n, m, l;
        while(true) {
        	String d = sc.next();
	        char[] a = d.toCharArray();
	        if(d.equals("-"))break;
	        n = a.length;
	        char[] c = new char[n];
	        m = sc.nextInt();
	        for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        }
	        for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        }
        	System.out.println();
        }
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i, j, k, n, m, l;
        while(true) {
        	String d = sc.next();
	        char[] a = d.toCharArray();
	        if(d.equals("-"))break;
	        n = a.length;
	        char[] c = new char[n];
	        m = sc.nextInt();
	        for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        }
	        for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        }
        	System.out.println();
        }
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i, j, k, n, m, l;
        while(true) {
        	String d = sc.next();
	        char[] a = d.toCharArray();
	        if(d.equals("-"))break;
	        n = a.length;
	        char[] c = new char[n];
	        m = sc.nextInt();
	        for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        }
	        for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        }
        	System.out.println();
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int i, j, k, n, m, l;
        while(true) {
        	String d = sc.next();
	        char[] a = d.toCharArray();
	        if(d.equals("-"))break;
	        n = a.length;
	        char[] c = new char[n];
	        m = sc.nextInt();
	        for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        }
	        for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        }
        	System.out.println();
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int i i j j k k n n m m l; l while(true) {
        	String d = sc.next();
	        char[] a = d.toCharArray();
	        if(d.equals("-"))break;
	        n = a.length;
	        char[] c = new char[n];
	        m = sc.nextInt();
	        for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        }
	        for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        }
        	System.out.println();
        } true {
        	String d = sc.next();
	        char[] a = d.toCharArray();
	        if(d.equals("-"))break;
	        n = a.length;
	        char[] c = new char[n];
	        m = sc.nextInt();
	        for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        }
	        for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        }
        	System.out.println();
        } String d = sc.next(); d sc.next() sc.next sc char[] a = d.toCharArray(); a d.toCharArray() d.toCharArray d if(d.equals("-"))break; d.equals("-") d.equals d "-" break; n = a.length n a.length a a.length char[] c = new char[n]; c new char[n] n m = sc.nextInt() m sc.nextInt() sc.nextInt sc for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        } i = 0; i = 0 i 0 i < m i m i++ i++ i {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        } {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        } k = 0 k 0 l = sc.nextInt() l sc.nextInt() sc.nextInt sc char[] b = new char[l]; b new char[l] l for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        } j = 0; j = 0 j 0 j < l j l j++ j++ j {
		        	b[j] = a[j];
		        } {
		        	b[j] = a[j];
		        } b[j] = a[j] b[j] b j a[j] a j for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    } j = l; j = l j l j < n j n j++ j++ j {
			    	c[k] = a[j];
			    	k++;
			    } {
			    	c[k] = a[j];
			    	k++;
			    } c[k] = a[j] c[k] c k a[j] a j k++ k for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    } j = 0; j = 0 j 0 j < l j l j++ j++ j {
			        c[k] = b[j];
			        k++;
			    } {
			        c[k] = b[j];
			        k++;
			    } c[k] = b[j] c[k] c k b[j] b j k++ k for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        } j = 0; j = 0 j 0 j < n j n j++ j++ j {
		        	a[j] = c[j];
		        } {
		        	a[j] = c[j];
		        } a[j] = c[j] a[j] a j c[j] c j for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        } i = 0; i = 0 i 0 i < n i n i++ i++ i {
	        	System.out.print(a[i]);
	        } {
	        	System.out.print(a[i]);
	        } System.out.print(a[i]) System.out.print System.out System System.out a[i] a i System.out.println() System.out.println System.out System System.out sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i, j, k, n, m, l;
        while(true) {
        	String d = sc.next();
	        char[] a = d.toCharArray();
	        if(d.equals("-"))break;
	        n = a.length;
	        char[] c = new char[n];
	        m = sc.nextInt();
	        for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        }
	        for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        }
        	System.out.println();
        }
        sc.close();
    }
} public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i, j, k, n, m, l;
        while(true) {
        	String d = sc.next();
	        char[] a = d.toCharArray();
	        if(d.equals("-"))break;
	        n = a.length;
	        char[] c = new char[n];
	        m = sc.nextInt();
	        for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        }
	        for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        }
        	System.out.println();
        }
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i, j, k, n, m, l;
        while(true) {
        	String d = sc.next();
	        char[] a = d.toCharArray();
	        if(d.equals("-"))break;
	        n = a.length;
	        char[] c = new char[n];
	        m = sc.nextInt();
	        for(i = 0; i < m; i++) {
	        	k = 0;
	        	l = sc.nextInt();
		        char[] b = new char[l];
	        	for(j = 0; j < l; j++) {
		        	b[j] = a[j];
		        }
		        for(j = l; j < n; j++) {
			    	c[k] = a[j];
			    	k++;
			    }
		        for(j = 0; j < l; j++) {
			        c[k] = b[j];
			        k++;
			    }
		        for(j = 0; j < n; j++) {
		        	a[j] = c[j];
		        }
	        }
	        for(i = 0; i < n; i++) {
	        	System.out.print(a[i]);
	        }
        	System.out.println();
        }
        sc.close();
    }
}
