import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words;
        words = scan.next();
        int n, cuting;
        
        while(!words.equals("-")){
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        }
        
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words;
        words = scan.next();
        int n, cuting;
        
        while(!words.equals("-")){
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        }
        
    }
} Main public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words;
        words = scan.next();
        int n, cuting;
        
        while(!words.equals("-")){
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        }
        
    } main {
        Scanner scan=new Scanner(System.in);
        String words;
        words = scan.next();
        int n, cuting;
        
        while(!words.equals("-")){
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        }
        
    } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) String words; words words = scan.next() words scan.next() scan.next scan int n n cuting; cuting while(!words.equals("-")){
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        } !words.equals("-") words.equals("-") words.equals words "-" {
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        } n=scan.nextInt() n scan.nextInt() scan.nextInt scan for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            } {
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            } cuting=scan.nextInt() cuting scan.nextInt() scan.nextInt scan words=words.substring(cuting)+words.substring(0, cuting) words words.substring(cuting)+words.substring(0, cuting) words.substring(cuting) words.substring words cuting words.substring(0, cuting) words.substring words 0 cuting System.out.println(words) System.out.println System.out System System.out words words=scan.next() words scan.next() scan.next scan String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words;
        words = scan.next();
        int n, cuting;
        
        while(!words.equals("-")){
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        }
        
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words;
        words = scan.next();
        int n, cuting;
        
        while(!words.equals("-")){
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        }
        
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words;
        words = scan.next();
        int n, cuting;
        
        while(!words.equals("-")){
            n=scan.nextInt();
            
            for(int i=0; i<n; i++){
                cuting=scan.nextInt();
                words=words.substring(cuting)+words.substring(0, cuting);
            }
                System.out.println(words);
            words=scan.next();
        }
        
    }
}
