import java.io.*;
import java.util.*;
import java.lang.Math;
import java.util.Arrays;

public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        
        while (true) {
            String S;
            int m;
            S = sc.next();
            if (S.equals("-"))
                break;
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h;
                h = sc.nextInt();
                String res;
                res = S.substring(h, S.length());
                res += S.substring(0, h);
                S = res;
            }
            System.out.println(S);
        }

    }
  
} import java.io.*; io.* java import java.util.*; util.* java import java.lang.Math; Math java.lang import java.util.Arrays; Arrays java.util public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        
        while (true) {
            String S;
            int m;
            S = sc.next();
            if (S.equals("-"))
                break;
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h;
                h = sc.nextInt();
                String res;
                res = S.substring(h, S.length());
                res += S.substring(0, h);
                S = res;
            }
            System.out.println(S);
        }

    }
  
} Main public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        
        while (true) {
            String S;
            int m;
            S = sc.next();
            if (S.equals("-"))
                break;
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h;
                h = sc.nextInt();
                String res;
                res = S.substring(h, S.length());
                res += S.substring(0, h);
                S = res;
            }
            System.out.println(S);
        }

    } main {

        Scanner sc = new Scanner(System.in);

        
        while (true) {
            String S;
            int m;
            S = sc.next();
            if (S.equals("-"))
                break;
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h;
                h = sc.nextInt();
                String res;
                res = S.substring(h, S.length());
                res += S.substring(0, h);
                S = res;
            }
            System.out.println(S);
        }

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

        Scanner sc = new Scanner(System.in);

        
        while (true) {
            String S;
            int m;
            S = sc.next();
            if (S.equals("-"))
                break;
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h;
                h = sc.nextInt();
                String res;
                res = S.substring(h, S.length());
                res += S.substring(0, h);
                S = res;
            }
            System.out.println(S);
        }

    }
  
} public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        
        while (true) {
            String S;
            int m;
            S = sc.next();
            if (S.equals("-"))
                break;
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h;
                h = sc.nextInt();
                String res;
                res = S.substring(h, S.length());
                res += S.substring(0, h);
                S = res;
            }
            System.out.println(S);
        }

    }
  
} Main
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.util.Arrays;

public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        
        while (true) {
            String S;
            int m;
            S = sc.next();
            if (S.equals("-"))
                break;
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h;
                h = sc.nextInt();
                String res;
                res = S.substring(h, S.length());
                res += S.substring(0, h);
                S = res;
            }
            System.out.println(S);
        }

    }
  
}
