import java.util.*;
import java.text.*;

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

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;){
            String w = sc.next();
            if(w.equals("-")) break;
            int m = sc.nextInt();
            for(int i = 0; i < m; i++) {
                int h = sc.nextInt();
                w = w.substring(h) + w.substring(0, h);
            }
            System.out.println(w);
        }
    }
}