import java.util.Scanner;

/**
 * Shuffle
 */
public class Main {

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

        String str;
        int m,n = 0;
        while (scan.hasNext()) {
            str = scan.next();
            if (str.equals("-")) {
                return;
            }
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            }
            System.out.println(str);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

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

        String str;
        int m,n = 0;
        while (scan.hasNext()) {
            str = scan.next();
            if (str.equals("-")) {
                return;
            }
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            }
            System.out.println(str);
        }
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        String str;
        int m,n = 0;
        while (scan.hasNext()) {
            str = scan.next();
            if (str.equals("-")) {
                return;
            }
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            }
            System.out.println(str);
        }
    } main {
        Scanner scan = new Scanner(System.in);

        String str;
        int m,n = 0;
        while (scan.hasNext()) {
            str = scan.next();
            if (str.equals("-")) {
                return;
            }
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            }
            System.out.println(str);
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str; str int m m n = 0; n 0 while (scan.hasNext()) {
            str = scan.next();
            if (str.equals("-")) {
                return;
            }
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            }
            System.out.println(str);
        } scan.hasNext() scan.hasNext scan {
            str = scan.next();
            if (str.equals("-")) {
                return;
            }
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            }
            System.out.println(str);
        } str = scan.next() str scan.next() scan.next scan if (str.equals("-")) {
                return;
            } str.equals("-") str.equals str "-" {
                return;
            } return; m = scan.nextInt() m scan.nextInt() scan.nextInt scan for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            } {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            } n = scan.nextInt() n scan.nextInt() scan.nextInt scan str = str.substring(n, str.length())
                        + str.substring(0, n) str str.substring(n, str.length())
                        + str.substring(0, n) str.substring(n, str.length()) str.substring str n str.length() str.length str str.substring(0, n) str.substring str 0 n System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main {

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

        String str;
        int m,n = 0;
        while (scan.hasNext()) {
            str = scan.next();
            if (str.equals("-")) {
                return;
            }
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            }
            System.out.println(str);
        }
    }
} public class Main {

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

        String str;
        int m,n = 0;
        while (scan.hasNext()) {
            str = scan.next();
            if (str.equals("-")) {
                return;
            }
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            }
            System.out.println(str);
        }
    }
} Main
import java.util.Scanner;

/**
 * Shuffle
 */
public class Main {

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

        String str;
        int m,n = 0;
        while (scan.hasNext()) {
            str = scan.next();
            if (str.equals("-")) {
                return;
            }
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                n = scan.nextInt();
                str = str.substring(n, str.length())
                        + str.substring(0, n);
            }
            System.out.println(str);
        }
    }
}