import java.util.Scanner;

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

	String before;
	int order;
	int num;
	String str1,str2;
	

	while(true){
	    before = in.next();
	   if(before.equals("-"))break;
	   num = in.nextInt();

	    for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    }
	    System.out.println(before);

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

	String before;
	int order;
	int num;
	String str1,str2;
	

	while(true){
	    before = in.next();
	   if(before.equals("-"))break;
	   num = in.nextInt();

	    for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    }
	    System.out.println(before);

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

	String before;
	int order;
	int num;
	String str1,str2;
	

	while(true){
	    before = in.next();
	   if(before.equals("-"))break;
	   num = in.nextInt();

	    for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    }
	    System.out.println(before);

	}
    } main {
	Scanner in = new Scanner(System.in);

	String before;
	int order;
	int num;
	String str1,str2;
	

	while(true){
	    before = in.next();
	   if(before.equals("-"))break;
	   num = in.nextInt();

	    for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    }
	    System.out.println(before);

	}
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String before; before int order; order int num; num String str1 str1 str2; str2 while(true){
	    before = in.next();
	   if(before.equals("-"))break;
	   num = in.nextInt();

	    for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    }
	    System.out.println(before);

	} true {
	    before = in.next();
	   if(before.equals("-"))break;
	   num = in.nextInt();

	    for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    }
	    System.out.println(before);

	} before = in.next() before in.next() in.next in if(before.equals("-"))break; before.equals("-") before.equals before "-" break; num = in.nextInt() num in.nextInt() in.nextInt in for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    } int i=0; int i=0; i 0 i<num i num i++ i++ i {
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    } {
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    } order = in.nextInt() order in.nextInt() in.nextInt in str2 = before.substring(0,order) str2 before.substring(0,order) before.substring before 0 order str1 = before.substring(order,before.length()) str1 before.substring(order,before.length()) before.substring before order before.length() before.length before before = str1+str2 before str1+str2 str1 str2 System.out.println(before) System.out.println System.out System System.out before String[] args args public class Main{
    public static void main(String[] args){
	Scanner in = new Scanner(System.in);

	String before;
	int order;
	int num;
	String str1,str2;
	

	while(true){
	    before = in.next();
	   if(before.equals("-"))break;
	   num = in.nextInt();

	    for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    }
	    System.out.println(before);

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

	String before;
	int order;
	int num;
	String str1,str2;
	

	while(true){
	    before = in.next();
	   if(before.equals("-"))break;
	   num = in.nextInt();

	    for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    }
	    System.out.println(before);

	}
    }
} Main
import java.util.Scanner;

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

	String before;
	int order;
	int num;
	String str1,str2;
	

	while(true){
	    before = in.next();
	   if(before.equals("-"))break;
	   num = in.nextInt();

	    for(int i=0;i<num;i++){
		order = in.nextInt();
	    
		str2 = before.substring(0,order);
		str1 = before.substring(order,before.length());
		before = str1+str2;
	    }
	    System.out.println(before);

	}
    }
}

