import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m, n;
            String give = sc.next();
            if (give.equals("-")) break;

            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                n = sc.nextInt();
                String b = give.substring(n, give.length());
                String c = give.substring(0, n);
                give = b + c;
            }
            System.out.println(give);
        }

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m, n;
            String give = sc.next();
            if (give.equals("-")) break;

            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                n = sc.nextInt();
                String b = give.substring(n, give.length());
                String c = give.substring(0, n);
                give = b + c;
            }
            System.out.println(give);
        }

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m, n;
            String give = sc.next();
            if (give.equals("-")) break;

            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                n = sc.nextInt();
                String b = give.substring(n, give.length());
                String c = give.substring(0, n);
                give = b + c;
            }
            System.out.println(give);
        }

    } main {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m, n;
            String give = sc.next();
            if (give.equals("-")) break;

            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                n = sc.nextInt();
                String b = give.substring(n, give.length());
                String c = give.substring(0, n);
                give = b + c;
            }
            System.out.println(give);
        }

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (sc.hasNext()) {
            int m, n;
            String give = sc.next();
            if (give.equals("-")) break;

            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                n = sc.nextInt();
                String b = give.substring(n, give.length());
                String c = give.substring(0, n);
                give = b + c;
            }
            System.out.println(give);
        } sc.hasNext() sc.hasNext sc {
            int m, n;
            String give = sc.next();
            if (give.equals("-")) break;

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

            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                n = sc.nextInt();
                String b = give.substring(n, give.length());
                String c = give.substring(0, n);
                give = b + c;
            }
            System.out.println(give);
        }

    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m, n;
            String give = sc.next();
            if (give.equals("-")) break;

            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                n = sc.nextInt();
                String b = give.substring(n, give.length());
                String c = give.substring(0, n);
                give = b + c;
            }
            System.out.println(give);
        }

    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m, n;
            String give = sc.next();
            if (give.equals("-")) break;

            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                n = sc.nextInt();
                String b = give.substring(n, give.length());
                String c = give.substring(0, n);
                give = b + c;
            }
            System.out.println(give);
        }

    }
}
