import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        String cards = scn.next();

        while(!cards.equals("-")){
            int m = scn.nextInt();
            for(int i=0;i<m;i++){
                int h = scn.nextInt();
                String top = cards.substring(0,h);
                String bottom = cards.substring(h,cards.length());
                cards = bottom + top;
            }
            System.out.println(cards);
            cards = scn.next();
        }



    }

} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        String cards = scn.next();

        while(!cards.equals("-")){
            int m = scn.nextInt();
            for(int i=0;i<m;i++){
                int h = scn.nextInt();
                String top = cards.substring(0,h);
                String bottom = cards.substring(h,cards.length());
                cards = bottom + top;
            }
            System.out.println(cards);
            cards = scn.next();
        }



    }

} Main public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        String cards = scn.next();

        while(!cards.equals("-")){
            int m = scn.nextInt();
            for(int i=0;i<m;i++){
                int h = scn.nextInt();
                String top = cards.substring(0,h);
                String bottom = cards.substring(h,cards.length());
                cards = bottom + top;
            }
            System.out.println(cards);
            cards = scn.next();
        }



    } main {
        Scanner scn = new Scanner(System.in);
        String cards = scn.next();

        while(!cards.equals("-")){
            int m = scn.nextInt();
            for(int i=0;i<m;i++){
                int h = scn.nextInt();
                String top = cards.substring(0,h);
                String bottom = cards.substring(h,cards.length());
                cards = bottom + top;
            }
            System.out.println(cards);
            cards = scn.next();
        }



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

        while(!cards.equals("-")){
            int m = scn.nextInt();
            for(int i=0;i<m;i++){
                int h = scn.nextInt();
                String top = cards.substring(0,h);
                String bottom = cards.substring(h,cards.length());
                cards = bottom + top;
            }
            System.out.println(cards);
            cards = scn.next();
        }



    }

} public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        String cards = scn.next();

        while(!cards.equals("-")){
            int m = scn.nextInt();
            for(int i=0;i<m;i++){
                int h = scn.nextInt();
                String top = cards.substring(0,h);
                String bottom = cards.substring(h,cards.length());
                cards = bottom + top;
            }
            System.out.println(cards);
            cards = scn.next();
        }



    }

} Main
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        String cards = scn.next();

        while(!cards.equals("-")){
            int m = scn.nextInt();
            for(int i=0;i<m;i++){
                int h = scn.nextInt();
                String top = cards.substring(0,h);
                String bottom = cards.substring(h,cards.length());
                cards = bottom + top;
            }
            System.out.println(cards);
            cards = scn.next();
        }



    }

}
