import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        }
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        }
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        } true {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        } String deck = sc.nextLine(); deck sc.nextLine() sc.nextLine sc if (deck.equals("-")) {
                break;
            } deck.equals("-") deck.equals deck "-" {
                break;
            } break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            } {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            } int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc String part1 = deck.substring(h); part1 deck.substring(h) deck.substring deck h String part2 = deck.substring(0, h); part2 deck.substring(0, h) deck.substring deck 0 h deck = part1.concat(part2) deck part1.concat(part2) part1.concat part1 part2 System.out.println(deck) System.out.println System.out System System.out deck deck = sc.nextLine() deck sc.nextLine() sc.nextLine sc sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        }
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        }
        sc.close();
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String deck = sc.nextLine();
            if (deck.equals("-")) {
                break;
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String part1 = deck.substring(h);
                String part2 = deck.substring(0, h);
                deck = part1.concat(part2);
            }
            System.out.println(deck);
            deck = sc.nextLine();
        }
        sc.close();
    }
}
