import java.io.*;

public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int n, h;

        while(true){
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

            for(int i = 0; i < n; i++){
                h = Integer.parseInt(br.readLine());
                StringBuilder sb = new StringBuilder();
                sb.append(str.substring(h, str.length())).append(str.substring(0, h));
                str = sb.toString();
            }
            System.out.println(str);
        }
    }
} import java.io.*; io.* java public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int n, h;

        while(true){
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

            for(int i = 0; i < n; i++){
                h = Integer.parseInt(br.readLine());
                StringBuilder sb = new StringBuilder();
                sb.append(str.substring(h, str.length())).append(str.substring(0, h));
                str = sb.toString();
            }
            System.out.println(str);
        }
    }
} Main public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int n, h;

        while(true){
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

            for(int i = 0; i < n; i++){
                h = Integer.parseInt(br.readLine());
                StringBuilder sb = new StringBuilder();
                sb.append(str.substring(h, str.length())).append(str.substring(0, h));
                str = sb.toString();
            }
            System.out.println(str);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int n, h;

        while(true){
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

            for(int i = 0; i < n; i++){
                h = Integer.parseInt(br.readLine());
                StringBuilder sb = new StringBuilder();
                sb.append(str.substring(h, str.length())).append(str.substring(0, h));
                str = sb.toString();
            }
            System.out.println(str);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str int n n h; h while(true){
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

            for(int i = 0; i < n; i++){
                h = Integer.parseInt(br.readLine());
                StringBuilder sb = new StringBuilder();
                sb.append(str.substring(h, str.length())).append(str.substring(0, h));
                str = sb.toString();
            }
            System.out.println(str);
        } true {
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

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

        while(true){
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

            for(int i = 0; i < n; i++){
                h = Integer.parseInt(br.readLine());
                StringBuilder sb = new StringBuilder();
                sb.append(str.substring(h, str.length())).append(str.substring(0, h));
                str = sb.toString();
            }
            System.out.println(str);
        }
    }
} public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int n, h;

        while(true){
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

            for(int i = 0; i < n; i++){
                h = Integer.parseInt(br.readLine());
                StringBuilder sb = new StringBuilder();
                sb.append(str.substring(h, str.length())).append(str.substring(0, h));
                str = sb.toString();
            }
            System.out.println(str);
        }
    }
} Main
import java.io.*;

public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int n, h;

        while(true){
            str = br.readLine();
            if(str.equals("-")){
                break;
            }
            n = Integer.parseInt(br.readLine());

            for(int i = 0; i < n; i++){
                h = Integer.parseInt(br.readLine());
                StringBuilder sb = new StringBuilder();
                sb.append(str.substring(h, str.length())).append(str.substring(0, h));
                str = sb.toString();
            }
            System.out.println(str);
        }
    }
}