import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String word = "";		//???????????????string
		int[] shuffleBegin = new int[100]; //?????£?????????????§????
		String temp = "";
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			}
			
			for(int i =0;i<shuffleTimes; i++){
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			}
			System.out.println(word);		
			
		}
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String word = "";		//???????????????string
		int[] shuffleBegin = new int[100]; //?????£?????????????§????
		String temp = "";
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			}
			
			for(int i =0;i<shuffleTimes; i++){
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			}
			System.out.println(word);		
			
		}
	}
} Main public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String word = "";		//???????????????string
		int[] shuffleBegin = new int[100]; //?????£?????????????§????
		String temp = "";
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			}
			
			for(int i =0;i<shuffleTimes; i++){
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			}
			System.out.println(word);		
			
		}
	} main {
		Scanner scan = new Scanner(System.in);
		String word = "";		//???????????????string
		int[] shuffleBegin = new int[100]; //?????£?????????????§????
		String temp = "";
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			}
			
			for(int i =0;i<shuffleTimes; i++){
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			}
			System.out.println(word);		
			
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String word = ""; word "" int[] shuffleBegin = new int[100]; shuffleBegin new int[100] 100 String temp = ""; temp "" while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			}
			
			for(int i =0;i<shuffleTimes; i++){
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			}
			System.out.println(word);		
			
		} true {
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			}
			
			for(int i =0;i<shuffleTimes; i++){
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			}
			System.out.println(word);		
			
		} temp = scan.next() temp scan.next() scan.next scan if(temp.equals("-")){
				break;
			} temp.equals("-") temp.equals temp "-" {
				break;
			} break; char[] targetChar = temp.toCharArray(); targetChar temp.toCharArray() temp.toCharArray temp int targetLength = temp.length(); targetLength temp.length() temp.length temp int shuffleTimes = scan.nextInt(); shuffleTimes scan.nextInt() scan.nextInt scan for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			} int i=0; int i=0; i 0 i<shuffleTimes i shuffleTimes i++ i++ i {
				shuffleBegin[i] = scan.nextInt();
			} {
				shuffleBegin[i] = scan.nextInt();
			} shuffleBegin[i] = scan.nextInt() shuffleBegin[i] shuffleBegin i scan.nextInt() scan.nextInt scan for(int i =0;i<shuffleTimes; i++){
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			} int i =0; int i =0; i 0 i<shuffleTimes i shuffleTimes i++ i++ i {
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			} {
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			} word = "" word "" for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				} int j=0; int j=0; j 0 j<(targetLength - shuffleBegin[i]) j (targetLength - shuffleBegin[i]) targetLength shuffleBegin[i] shuffleBegin i j++ j++ j {
					word = word + targetChar[j + shuffleBegin[i]];
				} {
					word = word + targetChar[j + shuffleBegin[i]];
				} word = word + targetChar[j + shuffleBegin[i]] word word + targetChar[j + shuffleBegin[i]] word targetChar[j + shuffleBegin[i]] targetChar j + shuffleBegin[i] j shuffleBegin[i] shuffleBegin i for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				} int j=0; int j=0; j 0 j<shuffleBegin[i] j shuffleBegin[i] shuffleBegin i j++ j++ j {
					word = word + targetChar[j];
				} {
					word = word + targetChar[j];
				} word = word + targetChar[j] word word + targetChar[j] word targetChar[j] targetChar j targetChar = word.toCharArray() targetChar word.toCharArray() word.toCharArray word System.out.println(word) System.out.println System.out System System.out word String[] args args
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String word = "";		//???????????????string
		int[] shuffleBegin = new int[100]; //?????£?????????????§????
		String temp = "";
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			}
			
			for(int i =0;i<shuffleTimes; i++){
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			}
			System.out.println(word);		
			
		}
	}
}