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

class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        
        while(true){
            String s = scan.next();
            
            if(s.equals("-")){
                break;
            }
            
            int m = scan.nextInt();
            
            for(int i = 0; i < m; ++i){
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            }
            
            System.out.println(s);
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java import java.lang.*; lang.* java class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        
        while(true){
            String s = scan.next();
            
            if(s.equals("-")){
                break;
            }
            
            int m = scan.nextInt();
            
            for(int i = 0; i < m; ++i){
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            }
            
            System.out.println(s);
        }
    }
} Main public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        
        while(true){
            String s = scan.next();
            
            if(s.equals("-")){
                break;
            }
            
            int m = scan.nextInt();
            
            for(int i = 0; i < m; ++i){
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            }
            
            System.out.println(s);
        }
    } main {
        Scanner scan = new Scanner(System.in);
        
        while(true){
            String s = scan.next();
            
            if(s.equals("-")){
                break;
            }
            
            int m = scan.nextInt();
            
            for(int i = 0; i < m; ++i){
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            }
            
            System.out.println(s);
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true){
            String s = scan.next();
            
            if(s.equals("-")){
                break;
            }
            
            int m = scan.nextInt();
            
            for(int i = 0; i < m; ++i){
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            }
            
            System.out.println(s);
        } true {
            String s = scan.next();
            
            if(s.equals("-")){
                break;
            }
            
            int m = scan.nextInt();
            
            for(int i = 0; i < m; ++i){
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            }
            
            System.out.println(s);
        } String s = scan.next(); s scan.next() scan.next scan if(s.equals("-")){
                break;
            } s.equals("-") s.equals s "-" {
                break;
            } break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan for(int i = 0; i < m; ++i){
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            } int i = 0; int i = 0; i 0 i < m i m ++i ++i i {
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            } {
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            } int h    = scan.nextInt(); h scan.nextInt() scan.nextInt scan String t = s.substring(0, h); t s.substring(0, h) s.substring s 0 h String b = s.substring(h); b s.substring(h) s.substring s h s = b + t s b + t b t System.out.println(s) System.out.println System.out System System.out s String [] args args
import java.io.*;
import java.util.*;
import java.lang.*;

class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        
        while(true){
            String s = scan.next();
            
            if(s.equals("-")){
                break;
            }
            
            int m = scan.nextInt();
            
            for(int i = 0; i < m; ++i){
                int h    = scan.nextInt();
                String t = s.substring(0, h);
                String b = s.substring(h);
                
                s = b + t;
            }
            
            System.out.println(s);
        }
    }
}
