import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
		    String text = sc.next();
		    if ("-".equals(text)) {
		        break;
		    }
		    //行数
		    int n = sc.nextInt();
		    for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    }
            System.out.println(text);
		}
		
        
		
		
    }
}
 import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
		    String text = sc.next();
		    if ("-".equals(text)) {
		        break;
		    }
		    //行数
		    int n = sc.nextInt();
		    for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    }
            System.out.println(text);
		}
		
        
		
		
    }
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
		    String text = sc.next();
		    if ("-".equals(text)) {
		        break;
		    }
		    //行数
		    int n = sc.nextInt();
		    for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    }
            System.out.println(text);
		}
		
        
		
		
    } main {
		Scanner sc = new Scanner(System.in);
		while (true) {
		    String text = sc.next();
		    if ("-".equals(text)) {
		        break;
		    }
		    //行数
		    int n = sc.nextInt();
		    for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    }
            System.out.println(text);
		}
		
        
		
		
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
		    String text = sc.next();
		    if ("-".equals(text)) {
		        break;
		    }
		    //行数
		    int n = sc.nextInt();
		    for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    }
            System.out.println(text);
		} true {
		    String text = sc.next();
		    if ("-".equals(text)) {
		        break;
		    }
		    //行数
		    int n = sc.nextInt();
		    for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    }
            System.out.println(text);
		} String text = sc.next(); text sc.next() sc.next sc if ("-".equals(text)) {
		        break;
		    } "-".equals(text) "-".equals "-" text {
		        break;
		    } break; int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    } {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    } int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc String s1 = text.substring(0, x); s1 text.substring(0, x) text.substring text 0 x String s2 = text.substring(x); s2 text.substring(x) text.substring text x text = s2 + s1 text s2 + s1 s2 s1 System.out.println(text) System.out.println System.out System System.out text String[] args args public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
		    String text = sc.next();
		    if ("-".equals(text)) {
		        break;
		    }
		    //行数
		    int n = sc.nextInt();
		    for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    }
            System.out.println(text);
		}
		
        
		
		
    }
} public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
		    String text = sc.next();
		    if ("-".equals(text)) {
		        break;
		    }
		    //行数
		    int n = sc.nextInt();
		    for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    }
            System.out.println(text);
		}
		
        
		
		
    }
} Main
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
		    String text = sc.next();
		    if ("-".equals(text)) {
		        break;
		    }
		    //行数
		    int n = sc.nextInt();
		    for (int i = 0; i < n; i++) {
		        int x = sc.nextInt();
		        String s1 = text.substring(0, x);
		        String s2 = text.substring(x);
		        text = s2 + s1;
		    }
            System.out.println(text);
		}
		
        
		
		
    }
}

