import java.io.*;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out=new StringBuilder();
        String str;
        int q=0;
        while((str=br.readLine()).equals("-")==false){
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        }

        int index = out.lastIndexOf("\n");

        out.deleteCharAt(index);
        System.out.println(out);
    }
} import java.io.*; io.* java public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out=new StringBuilder();
        String str;
        int q=0;
        while((str=br.readLine()).equals("-")==false){
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        }

        int index = out.lastIndexOf("\n");

        out.deleteCharAt(index);
        System.out.println(out);
    }
} Main public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out=new StringBuilder();
        String str;
        int q=0;
        while((str=br.readLine()).equals("-")==false){
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        }

        int index = out.lastIndexOf("\n");

        out.deleteCharAt(index);
        System.out.println(out);
    } main {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out=new StringBuilder();
        String str;
        int q=0;
        while((str=br.readLine()).equals("-")==false){
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        }

        int index = out.lastIndexOf("\n");

        out.deleteCharAt(index);
        System.out.println(out);
    } BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder out=new StringBuilder(); out new StringBuilder() String str; str int q=0; q 0 while((str=br.readLine()).equals("-")==false){
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        } (str=br.readLine()).equals("-")==false (str=br.readLine()).equals("-") (str=br.readLine()).equals (str=br.readLine()) str br.readLine() br.readLine br "-" false {
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        } StringBuilder sb=new StringBuilder(); sb new StringBuilder() sb.append(str) sb.append sb str q=str.length() q str.length() str.length str int n=Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int p; p for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            } {
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            } p=Integer.parseInt(br.readLine()) p Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br sb.append(sb.substring(0,p)) sb.append sb sb.substring(0,p) sb.substring sb 0 p sb.delete(0,p) sb.delete sb 0 p out.append(sb+"\n") out.append out sb+"\n" sb "\n" int index = out.lastIndexOf("\n"); index out.lastIndexOf("\n") out.lastIndexOf out "\n" out.deleteCharAt(index) out.deleteCharAt out index System.out.println(out) System.out.println System.out System System.out out String[] args args public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out=new StringBuilder();
        String str;
        int q=0;
        while((str=br.readLine()).equals("-")==false){
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        }

        int index = out.lastIndexOf("\n");

        out.deleteCharAt(index);
        System.out.println(out);
    }
} public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out=new StringBuilder();
        String str;
        int q=0;
        while((str=br.readLine()).equals("-")==false){
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        }

        int index = out.lastIndexOf("\n");

        out.deleteCharAt(index);
        System.out.println(out);
    }
} Main
import java.io.*;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out=new StringBuilder();
        String str;
        int q=0;
        while((str=br.readLine()).equals("-")==false){
            StringBuilder sb=new StringBuilder();
            sb.append(str);
            q=str.length();
            int n=Integer.parseInt(br.readLine());
            int p;
            for(int i=0;i<n;i++){
                p=Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,p));
                sb.delete(0,p);
            }
            out.append(sb+"\n");
        }

        int index = out.lastIndexOf("\n");

        out.deleteCharAt(index);
        System.out.println(out);
    }
}