import java.util.List;
import java.util.ArrayList;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String str = sc.next();
        String[] strArray = str.split("");

        while (!str.equals("-")) {

            Queue<String> queue = new ArrayDeque<>();

            for (int i = 0; i < strArray.length; i++) {
                queue.add(strArray[i]);
            }

            int m = sc.nextInt();
            List<Integer> h = new ArrayList<>();

            for (int i = 0; i < m; i++) {
                h.add(sc.nextInt());
            }

            for (int i = 0; i < h.size(); i++) {
                for (int j = 0; j < h.get(i); j++) {
                    queue.add(queue.poll());
                }
            }

            for (int i = 0; i < strArray.length; i++) {
                System.out.print(queue.poll());
            }

            System.out.print("\n");

            str = sc.next();
            strArray = str.split("");
        }

        sc.close();
    }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz