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());
        }
    }
} import java.io.*; io.* java 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());
        }
    }
} 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());
        }
    } main {
        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());
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder cards = new StringBuilder(); cards new StringBuilder() int count; count int i; i int h; 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());
        } !cards.append(br.readLine()).toString().equals("-") cards.append(br.readLine()).toString().equals("-") cards.append(br.readLine()).toString().equals cards.append(br.readLine()).toString() cards.append(br.readLine()).toString cards.append(br.readLine()) cards.append cards br.readLine() br.readLine br "-" {
            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());
        } count = Integer.parseInt(br.readLine()) count Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (i = 0; i < count; i++) {
                h = Integer.parseInt(br.readLine());
                String subStr = cards.substring(0, h);
                cards.delete(0, h);
                cards.append(subStr);
            } i = 0; i = 0 i 0 i < count i count i++ i++ i {
                h = Integer.parseInt(br.readLine());
                String subStr = cards.substring(0, h);
                cards.delete(0, h);
                cards.append(subStr);
            } {
                h = Integer.parseInt(br.readLine());
                String subStr = cards.substring(0, h);
                cards.delete(0, h);
                cards.append(subStr);
            } h = Integer.parseInt(br.readLine()) h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br String subStr = cards.substring(0, h); subStr cards.substring(0, h) cards.substring cards 0 h cards.delete(0, h) cards.delete cards 0 h cards.append(subStr) cards.append cards subStr System.out.println(cards) System.out.println System.out System System.out cards cards.delete(0, cards.length()) cards.delete cards 0 cards.length() cards.length cards String[] args args
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());
        }
    }
}