import java.util.Scanner;

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

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

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

	while(true){
        String W1;
        int m = 0,h=0;
        
        String W = sc.next();
        if(W.equals("-"))
           break;
        
        m = sc.nextInt();;
        for(int i=0 ; i<m;i++){
        	h = sc.nextInt();
        	W1= "";
        	W1+=W.substring(h,(W.length()));
       		W1+=W.substring(0,h);
            W=W1;
		}
        System.out.println(W);
    }
        
    
	} main {
	Scanner sc = new Scanner(System.in);

	while(true){
        String W1;
        int m = 0,h=0;
        
        String W = sc.next();
        if(W.equals("-"))
           break;
        
        m = sc.nextInt();;
        for(int i=0 ; i<m;i++){
        	h = sc.nextInt();
        	W1= "";
        	W1+=W.substring(h,(W.length()));
       		W1+=W.substring(0,h);
            W=W1;
		}
        System.out.println(W);
    }
        
    
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
        String W1;
        int m = 0,h=0;
        
        String W = sc.next();
        if(W.equals("-"))
           break;
        
        m = sc.nextInt();;
        for(int i=0 ; i<m;i++){
        	h = sc.nextInt();
        	W1= "";
        	W1+=W.substring(h,(W.length()));
       		W1+=W.substring(0,h);
            W=W1;
		}
        System.out.println(W);
    } true {
        String W1;
        int m = 0,h=0;
        
        String W = sc.next();
        if(W.equals("-"))
           break;
        
        m = sc.nextInt();;
        for(int i=0 ; i<m;i++){
        	h = sc.nextInt();
        	W1= "";
        	W1+=W.substring(h,(W.length()));
       		W1+=W.substring(0,h);
            W=W1;
		}
        System.out.println(W);
    } String W1; W1 int m = 0 m 0 h=0; h 0 String W = sc.next(); W sc.next() sc.next sc if(W.equals("-"))
           break; W.equals("-") W.equals W "-" break; m = sc.nextInt() m sc.nextInt() sc.nextInt sc for(int i=0 ; i<m;i++){
        	h = sc.nextInt();
        	W1= "";
        	W1+=W.substring(h,(W.length()));
       		W1+=W.substring(0,h);
            W=W1;
		} int i=0 ; int i=0 ; i 0 i<m i m i++ i++ i {
        	h = sc.nextInt();
        	W1= "";
        	W1+=W.substring(h,(W.length()));
       		W1+=W.substring(0,h);
            W=W1;
		} {
        	h = sc.nextInt();
        	W1= "";
        	W1+=W.substring(h,(W.length()));
       		W1+=W.substring(0,h);
            W=W1;
		} h = sc.nextInt() h sc.nextInt() sc.nextInt sc W1= "" W1 "" W1+=W.substring(h,(W.length())) W1 W.substring(h,(W.length())) W.substring W h (W.length()) W.length W W1+=W.substring(0,h) W1 W.substring(0,h) W.substring W 0 h W=W1 W W1 System.out.println(W) System.out.println System.out System System.out W String[]args args
import java.util.Scanner;

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

	while(true){
        String W1;
        int m = 0,h=0;
        
        String W = sc.next();
        if(W.equals("-"))
           break;
        
        m = sc.nextInt();;
        for(int i=0 ; i<m;i++){
        	h = sc.nextInt();
        	W1= "";
        	W1+=W.substring(h,(W.length()));
       		W1+=W.substring(0,h);
            W=W1;
		}
        System.out.println(W);
    }
        
    
	}
}
