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