import java.util.Scanner;

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

        while (!(input = sc.next()).equals("-")) {
            m = sc.nextInt();
            int[] h = new int[m];
            char[] output = new char[input.length()];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }
            for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            }

            for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            }
            for (char c : output) System.out.print(c);
            System.out.println();
        }
    }

    public static char[] change(char[] input, int length, int n) {
        char[] output = new char[length];

        for (int i = 0; i < length - n; i++) {
            output[i] = input[i+n];
        }
        for (int i = length - n; i < length; i++) {
            output[i] = input[i + n - length];
        }

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

        while (!(input = sc.next()).equals("-")) {
            m = sc.nextInt();
            int[] h = new int[m];
            char[] output = new char[input.length()];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }
            for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            }

            for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            }
            for (char c : output) System.out.print(c);
            System.out.println();
        }
    }

    public static char[] change(char[] input, int length, int n) {
        char[] output = new char[length];

        for (int i = 0; i < length - n; i++) {
            output[i] = input[i+n];
        }
        for (int i = length - n; i < length; i++) {
            output[i] = input[i + n - length];
        }

        return output;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input;
        int m;

        while (!(input = sc.next()).equals("-")) {
            m = sc.nextInt();
            int[] h = new int[m];
            char[] output = new char[input.length()];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }
            for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            }

            for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            }
            for (char c : output) System.out.print(c);
            System.out.println();
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String input;
        int m;

        while (!(input = sc.next()).equals("-")) {
            m = sc.nextInt();
            int[] h = new int[m];
            char[] output = new char[input.length()];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }
            for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            }

            for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            }
            for (char c : output) System.out.print(c);
            System.out.println();
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input; input int m; m while (!(input = sc.next()).equals("-")) {
            m = sc.nextInt();
            int[] h = new int[m];
            char[] output = new char[input.length()];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }
            for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            }

            for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            }
            for (char c : output) System.out.print(c);
            System.out.println();
        } !(input = sc.next()).equals("-") (input = sc.next()).equals("-") (input = sc.next()).equals (input = sc.next()) input sc.next() sc.next sc "-" {
            m = sc.nextInt();
            int[] h = new int[m];
            char[] output = new char[input.length()];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }
            for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            }

            for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            }
            for (char c : output) System.out.print(c);
            System.out.println();
        } m = sc.nextInt() m sc.nextInt() sc.nextInt sc int[] h = new int[m]; h new int[m] m char[] output = new char[input.length()]; output new char[input.length()] input.length() input.length input for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                h[i] = sc.nextInt();
            } {
                h[i] = sc.nextInt();
            } h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            } int i = 0; int i = 0; i 0 i < input.length() i input.length() input.length input i++ i++ i {
                output[i] = input.charAt(i);
            } {
                output[i] = input.charAt(i);
            } output[i] = input.charAt(i) output[i] output i input.charAt(i) input.charAt input i for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                output = change(output, input.length(), h[i]);
            } {
                output = change(output, input.length(), h[i]);
            } output = change(output, input.length(), h[i]) output change(output, input.length(), h[i]) change output input.length() input.length input h[i] h i for (char c : output) System.out.print(c); char c output System.out.print(c); System.out.print(c) System.out.print System.out System System.out c System.out.println() System.out.println System.out System System.out String[] args args public static char[] change(char[] input, int length, int n) {
        char[] output = new char[length];

        for (int i = 0; i < length - n; i++) {
            output[i] = input[i+n];
        }
        for (int i = length - n; i < length; i++) {
            output[i] = input[i + n - length];
        }

        return output;
    } change {
        char[] output = new char[length];

        for (int i = 0; i < length - n; i++) {
            output[i] = input[i+n];
        }
        for (int i = length - n; i < length; i++) {
            output[i] = input[i + n - length];
        }

        return output;
    } char[] output = new char[length]; output new char[length] length for (int i = 0; i < length - n; i++) {
            output[i] = input[i+n];
        } int i = 0; int i = 0; i 0 i < length - n i length - n length n i++ i++ i {
            output[i] = input[i+n];
        } {
            output[i] = input[i+n];
        } output[i] = input[i+n] output[i] output i input[i+n] input i+n i n for (int i = length - n; i < length; i++) {
            output[i] = input[i + n - length];
        } int i = length - n; int i = length - n; i length - n length n i < length i length i++ i++ i {
            output[i] = input[i + n - length];
        } {
            output[i] = input[i + n - length];
        } output[i] = input[i + n - length] output[i] output i input[i + n - length] input i + n - length i + n i n length return output; output char[] input input int length length int n n public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input;
        int m;

        while (!(input = sc.next()).equals("-")) {
            m = sc.nextInt();
            int[] h = new int[m];
            char[] output = new char[input.length()];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }
            for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            }

            for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            }
            for (char c : output) System.out.print(c);
            System.out.println();
        }
    }

    public static char[] change(char[] input, int length, int n) {
        char[] output = new char[length];

        for (int i = 0; i < length - n; i++) {
            output[i] = input[i+n];
        }
        for (int i = length - n; i < length; i++) {
            output[i] = input[i + n - length];
        }

        return output;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input;
        int m;

        while (!(input = sc.next()).equals("-")) {
            m = sc.nextInt();
            int[] h = new int[m];
            char[] output = new char[input.length()];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }
            for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            }

            for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            }
            for (char c : output) System.out.print(c);
            System.out.println();
        }
    }

    public static char[] change(char[] input, int length, int n) {
        char[] output = new char[length];

        for (int i = 0; i < length - n; i++) {
            output[i] = input[i+n];
        }
        for (int i = length - n; i < length; i++) {
            output[i] = input[i + n - length];
        }

        return output;
    }
} Main
import java.util.Scanner;

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

        while (!(input = sc.next()).equals("-")) {
            m = sc.nextInt();
            int[] h = new int[m];
            char[] output = new char[input.length()];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }
            for (int i = 0; i < input.length(); i++) {
                output[i] = input.charAt(i);
            }

            for (int i = 0; i < m; i++) {
                output = change(output, input.length(), h[i]);
            }
            for (char c : output) System.out.print(c);
            System.out.println();
        }
    }

    public static char[] change(char[] input, int length, int n) {
        char[] output = new char[length];

        for (int i = 0; i < length - n; i++) {
            output[i] = input[i+n];
        }
        for (int i = length - n; i < length; i++) {
            output[i] = input[i + n - length];
        }

        return output;
    }
}
