import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder cards = new StringBuilder();
        int count;
        int i;
        int h;
        while (!cards.append(br.readLine()).toString().equals("-")) {
            count = Integer.parseInt(br.readLine());
            for (i = 0; i < count; i++) {
                h = Integer.parseInt(br.readLine());
                String subStr = cards.substring(0, h);
                cards.delete(0, h);
                cards.append(subStr);
            }
            System.out.println(cards);
            cards.delete(0, cards.length());
        }
    }
}
/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