import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int m, h;
        String deck, temp1, temp2;
        Scanner sc = new Scanner(System.in);
        deck = sc.next();
        
        while (!deck.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            }
            System.out.println(deck);
            deck = sc.next();
        }
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        int m, h;
        String deck, temp1, temp2;
        Scanner sc = new Scanner(System.in);
        deck = sc.next();
        
        while (!deck.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            }
            System.out.println(deck);
            deck = sc.next();
        }
    }
} Main public static void main(String[] args) {
        int m, h;
        String deck, temp1, temp2;
        Scanner sc = new Scanner(System.in);
        deck = sc.next();
        
        while (!deck.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            }
            System.out.println(deck);
            deck = sc.next();
        }
    } main {
        int m, h;
        String deck, temp1, temp2;
        Scanner sc = new Scanner(System.in);
        deck = sc.next();
        
        while (!deck.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            }
            System.out.println(deck);
            deck = sc.next();
        }
    } int m m h; h String deck deck temp1 temp1 temp2; temp2 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) deck = sc.next() deck sc.next() sc.next sc while (!deck.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            }
            System.out.println(deck);
            deck = sc.next();
        } !deck.equals("-") deck.equals("-") deck.equals deck "-" {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            }
            System.out.println(deck);
            deck = sc.next();
        } m = sc.nextInt() m sc.nextInt() sc.nextInt sc for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            } {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            } h = sc.nextInt() h sc.nextInt() sc.nextInt sc temp1 = deck.substring(0, h) temp1 deck.substring(0, h) deck.substring deck 0 h temp2 = deck.substring(h, deck.length()) temp2 deck.substring(h, deck.length()) deck.substring deck h deck.length() deck.length deck temp2 += temp1 temp2 temp1 deck = temp2 deck temp2 System.out.println(deck) System.out.println System.out System System.out deck deck = sc.next() deck sc.next() sc.next sc String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int m, h;
        String deck, temp1, temp2;
        Scanner sc = new Scanner(System.in);
        deck = sc.next();
        
        while (!deck.equals("-")) {
            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                h = sc.nextInt();
                temp1 = deck.substring(0, h);
                temp2 = deck.substring(h, deck.length());
                temp2 += temp1;
                deck = temp2;
            }
            System.out.println(deck);
            deck = sc.next();
        }
    }
}
