import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,n,m; 
        String line,chr;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if("-".equals(str)) break;
            n = Integer.parseInt(in.readLine());
            for(i=0;i<n;i++){
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            }
            System.out.println(str);
        }
        System.out.flush();
    }
} import java.io.*; io.* java import java.util.Arrays; Arrays java.util class Main{
    public static void main(String[] args) throws IOException {
        int i,n,m; 
        String line,chr;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if("-".equals(str)) break;
            n = Integer.parseInt(in.readLine());
            for(i=0;i<n;i++){
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            }
            System.out.println(str);
        }
        System.out.flush();
    }
} Main public static void main(String[] args) throws IOException {
        int i,n,m; 
        String line,chr;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if("-".equals(str)) break;
            n = Integer.parseInt(in.readLine());
            for(i=0;i<n;i++){
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            }
            System.out.println(str);
        }
        System.out.flush();
    } main {
        int i,n,m; 
        String line,chr;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if("-".equals(str)) break;
            n = Integer.parseInt(in.readLine());
            for(i=0;i<n;i++){
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            }
            System.out.println(str);
        }
        System.out.flush();
    } int i i n n m; m String line line chr; chr String str; str BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) for(;;){
            str = in.readLine();
            if("-".equals(str)) break;
            n = Integer.parseInt(in.readLine());
            for(i=0;i<n;i++){
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            }
            System.out.println(str);
        } ; {
            str = in.readLine();
            if("-".equals(str)) break;
            n = Integer.parseInt(in.readLine());
            for(i=0;i<n;i++){
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            }
            System.out.println(str);
        } {
            str = in.readLine();
            if("-".equals(str)) break;
            n = Integer.parseInt(in.readLine());
            for(i=0;i<n;i++){
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            }
            System.out.println(str);
        } str = in.readLine() str in.readLine() in.readLine in if("-".equals(str)) break; "-".equals(str) "-".equals "-" str break; n = Integer.parseInt(in.readLine()) n Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in for(i=0;i<n;i++){
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            } i=0; i=0 i 0 i<n i n i++ i++ i {
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            } {
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            } m = Integer.parseInt(in.readLine()) m Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in chr = str.substring(0,m) chr str.substring(0,m) str.substring str 0 m line = str.substring(m,str.length()) line str.substring(m,str.length()) str.substring str m str.length() str.length str str = line+chr str line+chr line chr System.out.println(str) System.out.println System.out System System.out str System.out.flush() System.out.flush System.out System System.out String[] args args
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,n,m; 
        String line,chr;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if("-".equals(str)) break;
            n = Integer.parseInt(in.readLine());
            for(i=0;i<n;i++){
                m = Integer.parseInt(in.readLine());
                chr = str.substring(0,m);
                line = str.substring(m,str.length());
                str = line+chr;
            }
            System.out.println(str);
        }
        System.out.flush();
    }
}