import java.io.*;
import java.util.*;

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

        while((str = br.readLine()) != null){
            if(str.equals("-")){
                break;
            }

           StringBuilder aabc =new StringBuilder(str);
           int L = aabc.length();//4
           str = br.readLine();
           int m = Integer.parseInt(str);//3
           for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           }

           System.out.println(aabc.toString());
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        while((str = br.readLine()) != null){
            if(str.equals("-")){
                break;
            }

           StringBuilder aabc =new StringBuilder(str);
           int L = aabc.length();//4
           str = br.readLine();
           int m = Integer.parseInt(str);//3
           for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           }

           System.out.println(aabc.toString());
        }
    }
} Main public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        while((str = br.readLine()) != null){
            if(str.equals("-")){
                break;
            }

           StringBuilder aabc =new StringBuilder(str);
           int L = aabc.length();//4
           str = br.readLine();
           int m = Integer.parseInt(str);//3
           for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           }

           System.out.println(aabc.toString());
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        while((str = br.readLine()) != null){
            if(str.equals("-")){
                break;
            }

           StringBuilder aabc =new StringBuilder(str);
           int L = aabc.length();//4
           str = br.readLine();
           int m = Integer.parseInt(str);//3
           for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           }

           System.out.println(aabc.toString());
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str while((str = br.readLine()) != null){
            if(str.equals("-")){
                break;
            }

           StringBuilder aabc =new StringBuilder(str);
           int L = aabc.length();//4
           str = br.readLine();
           int m = Integer.parseInt(str);//3
           for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           }

           System.out.println(aabc.toString());
        } (str = br.readLine()) != null (str = br.readLine()) str br.readLine() br.readLine br null {
            if(str.equals("-")){
                break;
            }

           StringBuilder aabc =new StringBuilder(str);
           int L = aabc.length();//4
           str = br.readLine();
           int m = Integer.parseInt(str);//3
           for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           }

           System.out.println(aabc.toString());
        } if(str.equals("-")){
                break;
            } str.equals("-") str.equals str "-" {
                break;
            } break; StringBuilder aabc =new StringBuilder(str); aabc new StringBuilder(str) int L = aabc.length(); L aabc.length() aabc.length aabc str = br.readLine() str br.readLine() br.readLine br int m = Integer.parseInt(str); m Integer.parseInt(str) Integer.parseInt Integer str for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           } int i=0; int i=0; i 0 i<m i m i++ i++ i {
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           } {
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           } str = br.readLine() str br.readLine() br.readLine br int h = Integer.parseInt(str); h Integer.parseInt(str) Integer.parseInt Integer str String temp = aabc.substring(0,h); temp aabc.substring(0,h) aabc.substring aabc 0 h aabc.append(temp) aabc.append aabc temp aabc.delete(0,h) aabc.delete aabc 0 h System.out.println(aabc.toString()) System.out.println System.out System System.out aabc.toString() aabc.toString aabc String[] args args public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        while((str = br.readLine()) != null){
            if(str.equals("-")){
                break;
            }

           StringBuilder aabc =new StringBuilder(str);
           int L = aabc.length();//4
           str = br.readLine();
           int m = Integer.parseInt(str);//3
           for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           }

           System.out.println(aabc.toString());
        }
    }
} public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        while((str = br.readLine()) != null){
            if(str.equals("-")){
                break;
            }

           StringBuilder aabc =new StringBuilder(str);
           int L = aabc.length();//4
           str = br.readLine();
           int m = Integer.parseInt(str);//3
           for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           }

           System.out.println(aabc.toString());
        }
    }
} Main
import java.io.*;
import java.util.*;

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

        while((str = br.readLine()) != null){
            if(str.equals("-")){
                break;
            }

           StringBuilder aabc =new StringBuilder(str);
           int L = aabc.length();//4
           str = br.readLine();
           int m = Integer.parseInt(str);//3
           for(int i=0;i<m;i++){
            str = br.readLine();
            int h = Integer.parseInt(str);//1,2,1
            String temp = aabc.substring(0,h);//substring doesn't include index No of h
            aabc.append(temp);
            aabc.delete(0,h);
           }

           System.out.println(aabc.toString());
        }
    }
}