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