import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String line = sc.next();
        int m, h;

        String first, second;

        while (!line.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            }

            System.out.println(line);

            line = sc.next();

        }

        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String line = sc.next();
        int m, h;

        String first, second;

        while (!line.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            }

            System.out.println(line);

            line = sc.next();

        }

        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String line = sc.next();
        int m, h;

        String first, second;

        while (!line.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            }

            System.out.println(line);

            line = sc.next();

        }

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        String line = sc.next();
        int m, h;

        String first, second;

        while (!line.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            }

            System.out.println(line);

            line = sc.next();

        }

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.next(); line sc.next() sc.next sc int m m h; h String first first second; second while (!line.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            }

            System.out.println(line);

            line = sc.next();

        } !line.equals("-") line.equals("-") line.equals line "-" {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            }

            System.out.println(line);

            line = sc.next();

        } m = sc.nextInt() m sc.nextInt() sc.nextInt sc for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            } {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            } h = sc.nextInt() h sc.nextInt() sc.nextInt sc first = line.substring(0,h) first line.substring(0,h) line.substring line 0 h second = line.substring(h,line.length()) second line.substring(h,line.length()) line.substring line h line.length() line.length line line = second + first line second + first second first System.out.println(line) System.out.println System.out System System.out line line = sc.next() line sc.next() sc.next sc sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String line = sc.next();
        int m, h;

        String first, second;

        while (!line.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            }

            System.out.println(line);

            line = sc.next();

        }

        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String line = sc.next();
        int m, h;

        String first, second;

        while (!line.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            }

            System.out.println(line);

            line = sc.next();

        }

        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String line = sc.next();
        int m, h;

        String first, second;

        while (!line.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                first = line.substring(0,h);
                second = line.substring(h,line.length());

                line = second + first;
            }

            System.out.println(line);

            line = sc.next();

        }

        sc.close();
    }
}
