import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String originalSequence = "";
            while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            }
            if (originalSequence.equals("-")) {
                break;
            }
            ArrayDeque<Character> chars = new ArrayDeque<Character>();
            for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            }
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            }
            while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            }
            System.out.println("");
        }
    }
}
 import java.util.ArrayDeque; ArrayDeque java.util import java.util.ArrayList; ArrayList java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String originalSequence = "";
            while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            }
            if (originalSequence.equals("-")) {
                break;
            }
            ArrayDeque<Character> chars = new ArrayDeque<Character>();
            for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            }
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            }
            while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            }
            System.out.println("");
        }
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String originalSequence = "";
            while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            }
            if (originalSequence.equals("-")) {
                break;
            }
            ArrayDeque<Character> chars = new ArrayDeque<Character>();
            for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            }
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            }
            while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            }
            System.out.println("");
        }
    } main {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String originalSequence = "";
            while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            }
            if (originalSequence.equals("-")) {
                break;
            }
            ArrayDeque<Character> chars = new ArrayDeque<Character>();
            for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            }
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            }
            while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            }
            System.out.println("");
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while (true) {
            String originalSequence = "";
            while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            }
            if (originalSequence.equals("-")) {
                break;
            }
            ArrayDeque<Character> chars = new ArrayDeque<Character>();
            for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            }
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            }
            while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            }
            System.out.println("");
        } true {
            String originalSequence = "";
            while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            }
            if (originalSequence.equals("-")) {
                break;
            }
            ArrayDeque<Character> chars = new ArrayDeque<Character>();
            for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            }
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            }
            while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            }
            System.out.println("");
        } String originalSequence = ""; originalSequence "" while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            } originalSequence.length() == 0 originalSequence.length() originalSequence.length originalSequence 0 {
                originalSequence = scanner.nextLine();
            } originalSequence = scanner.nextLine() originalSequence scanner.nextLine() scanner.nextLine scanner if (originalSequence.equals("-")) {
                break;
            } originalSequence.equals("-") originalSequence.equals originalSequence "-" {
                break;
            } break; ArrayDeque<Character> chars = new ArrayDeque<Character>(); chars new ArrayDeque<Character>() for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            } int i = 0; int i = 0; i 0 i < originalSequence.length() i originalSequence.length() originalSequence.length originalSequence i++ i++ i {
                chars.add(originalSequence.charAt(i));
            } {
                chars.add(originalSequence.charAt(i));
            } chars.add(originalSequence.charAt(i)) chars.add chars originalSequence.charAt(i) originalSequence.charAt originalSequence i int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            } {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            } int h = scanner.nextInt(); h scanner.nextInt() scanner.nextInt scanner for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                } int j = 0; int j = 0; j 0 j < h j h j++ j++ j {
                    chars.add(chars.removeFirst());
                } {
                    chars.add(chars.removeFirst());
                } chars.add(chars.removeFirst()) chars.add chars chars.removeFirst() chars.removeFirst chars while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            } chars.size() > 0 chars.size() chars.size chars 0 {
                System.out.print(chars.removeFirst());
            } System.out.print(chars.removeFirst()) System.out.print System.out System System.out chars.removeFirst() chars.removeFirst chars System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String originalSequence = "";
            while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            }
            if (originalSequence.equals("-")) {
                break;
            }
            ArrayDeque<Character> chars = new ArrayDeque<Character>();
            for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            }
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            }
            while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            }
            System.out.println("");
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String originalSequence = "";
            while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            }
            if (originalSequence.equals("-")) {
                break;
            }
            ArrayDeque<Character> chars = new ArrayDeque<Character>();
            for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            }
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            }
            while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            }
            System.out.println("");
        }
    }
} Main
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String originalSequence = "";
            while (originalSequence.length() == 0) {
                originalSequence = scanner.nextLine();
            }
            if (originalSequence.equals("-")) {
                break;
            }
            ArrayDeque<Character> chars = new ArrayDeque<Character>();
            for (int i = 0; i < originalSequence.length(); i++) {
                chars.add(originalSequence.charAt(i));
            }
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int h = scanner.nextInt();
                for (int j = 0; j < h; j++) {
                    chars.add(chars.removeFirst());
                }
            }
            while (chars.size() > 0) {
                System.out.print(chars.removeFirst());
            }
            System.out.println("");
        }
    }
}

