import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String deck = scan.nextLine();
        while(!deck.equals("-")) {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        }
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String deck = scan.nextLine();
        while(!deck.equals("-")) {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        }
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String deck = scan.nextLine();
        while(!deck.equals("-")) {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        }
    } main {
        Scanner scan = new Scanner(System.in);
        String deck = scan.nextLine();
        while(!deck.equals("-")) {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String deck = scan.nextLine(); deck scan.nextLine() scan.nextLine scan while(!deck.equals("-")) {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        } !deck.equals("-") deck.equals("-") deck.equals deck "-" {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        } int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            } int x = 0; int x = 0; x 0 x < a x a x++ x++ x {
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            } {
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            } int s = scan.nextInt(); s scan.nextInt() scan.nextInt scan String half = deck.substring(0, s); half deck.substring(0, s) deck.substring deck 0 s String rest = deck.substring(s); rest deck.substring(s) deck.substring deck s deck = rest + half deck rest + half rest half System.out.println(deck) System.out.println System.out System System.out deck deck = scan.nextLine() deck scan.nextLine() scan.nextLine scan deck = scan.nextLine() deck scan.nextLine() scan.nextLine scan String[] args args public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String deck = scan.nextLine();
        while(!deck.equals("-")) {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        }
    }
} public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String deck = scan.nextLine();
        while(!deck.equals("-")) {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        }
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String deck = scan.nextLine();
        while(!deck.equals("-")) {
            int a = scan.nextInt();
            for(int x = 0; x < a; x++){
                int s = scan.nextInt();
                String half = deck.substring(0, s);
                String rest = deck.substring(s);
                deck = rest + half;
            }
            System.out.println(deck);
            deck = scan.nextLine();
            deck = scan.nextLine();
        }
    }
}
