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();
    }
} import java.util.List; List java.util import java.util.ArrayList; ArrayList java.util import java.util.Queue; Queue java.util import java.util.ArrayDeque; ArrayDeque java.util import java.util.Scanner; Scanner java.util 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();
    }
} 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();
    } main {

        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();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc String[] strArray = str.split(""); strArray str.split("") str.split str "" 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("");
        } !str.equals("-") str.equals("-") str.equals str "-" {

            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("");
        } Queue<String> queue = new ArrayDeque<>(); queue new ArrayDeque<>() for (int i = 0; i < strArray.length; i++) {
                queue.add(strArray[i]);
            } int i = 0; int i = 0; i 0 i < strArray.length i strArray.length strArray strArray.length i++ i++ i {
                queue.add(strArray[i]);
            } {
                queue.add(strArray[i]);
            } queue.add(strArray[i]) queue.add queue strArray[i] strArray i int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc List<Integer> h = new ArrayList<>(); h new ArrayList<>() for (int i = 0; i < m; i++) {
                h.add(sc.nextInt());
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                h.add(sc.nextInt());
            } {
                h.add(sc.nextInt());
            } h.add(sc.nextInt()) h.add h sc.nextInt() sc.nextInt sc for (int i = 0; i < h.size(); i++) {
                for (int j = 0; j < h.get(i); j++) {
                    queue.add(queue.poll());
                }
            } int i = 0; int i = 0; i 0 i < h.size() i h.size() h.size h i++ i++ i {
                for (int j = 0; j < h.get(i); j++) {
                    queue.add(queue.poll());
                }
            } {
                for (int j = 0; j < h.get(i); j++) {
                    queue.add(queue.poll());
                }
            } for (int j = 0; j < h.get(i); j++) {
                    queue.add(queue.poll());
                } int j = 0; int j = 0; j 0 j < h.get(i) j h.get(i) h.get h i j++ j++ j {
                    queue.add(queue.poll());
                } {
                    queue.add(queue.poll());
                } queue.add(queue.poll()) queue.add queue queue.poll() queue.poll queue for (int i = 0; i < strArray.length; i++) {
                System.out.print(queue.poll());
            } int i = 0; int i = 0; i 0 i < strArray.length i strArray.length strArray strArray.length i++ i++ i {
                System.out.print(queue.poll());
            } {
                System.out.print(queue.poll());
            } System.out.print(queue.poll()) System.out.print System.out System System.out queue.poll() queue.poll queue System.out.print("\n") System.out.print System.out System System.out "\n" str = sc.next() str sc.next() sc.next sc strArray = str.split("") strArray str.split("") str.split str "" sc.close() sc.close sc String[] args args 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();
    }
} 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();
    }
} Main
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();
    }
}
