import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int count = 1;
        int length[] = new int[10];

        while(true){
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    }
       
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int count = 1;
        int length[] = new int[10];

        while(true){
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    }
       
    }
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int count = 1;
        int length[] = new int[10];

        while(true){
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    }
       
    } main {
        Scanner sc = new Scanner(System.in);
        int count = 1;
        int length[] = new int[10];

        while(true){
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    }
       
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count = 1; count 1 int length[] = new int[10]; length new int[10] 10 while(true){
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    } true {
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    } String str = sc.next(); str sc.next() sc.next sc if(str.equals("-")) break; str.equals("-") str.equals str "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int h[] = new int[str.length()]; h new int[str.length()] str.length() str.length str char har[] = new char[1000]; har new char[1000] 1000 for(int i=0; i<m; i++) h[i] = sc.nextInt(); int i=0; int i=0; i 0 i<m i m i++ i++ i h[i] = sc.nextInt(); h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
            har[i] = str.charAt(i);
        
        } {
            har[i] = str.charAt(i);
        
        } har[i] = str.charAt(i) har[i] har i str.charAt(i) str.charAt str i for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        } int i=0; int i=0; i 0 i<m i m i++ i++ i {
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        } {
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        } for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            } int j=0; int j=0; j 0 j<h[i] j h[i] h i j++ j++ j {
                har[j+str.length()] = har[j];
            } {
                har[j+str.length()] = har[j];
            } har[j+str.length()] = har[j] har[j+str.length()] har j+str.length() j str.length() str.length str har[j] har j for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            } int j=0; int j=0; j 0 j<=str.length() j str.length() str.length str j++ j++ j {
                har[j] = har[j+h[i]];
            } {
                har[j] = har[j+h[i]];
            } har[j] = har[j+h[i]] har[j] har j har[j+h[i]] har j+h[i] j h[i] h i for(int i=0; i<str.length(); i++) System.out.print(har[i]); int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i System.out.print(har[i]); System.out.print(har[i]) System.out.print System.out System System.out har[i] har i System.out.println("") System.out.println System.out System System.out "" String args[] args public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int count = 1;
        int length[] = new int[10];

        while(true){
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    }
       
    }
} public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int count = 1;
        int length[] = new int[10];

        while(true){
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    }
       
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int count = 1;
        int length[] = new int[10];

        while(true){
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    }
       
    }
}
