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