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