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 answer = "";
		String temp = "";
		
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			int shuffleTimes = scan.nextInt();
			int shuffleBegin = 0;

			for(int i =0; i<shuffleTimes; i++){
				shuffleBegin = scan.nextInt();
				answer = "";

				for(int j=0; j<(targetLength - shuffleBegin) ; j++){
					answer = answer + targetChar[j + shuffleBegin];
				}
				for(int j=0; j<shuffleBegin; j++){
					answer = answer + targetChar[j];
				}
				targetChar = answer.toCharArray();
			}
			System.out.println(answer);
		}
	}
} 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 answer = "";
		String temp = "";
		
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			int shuffleTimes = scan.nextInt();
			int shuffleBegin = 0;

			for(int i =0; i<shuffleTimes; i++){
				shuffleBegin = scan.nextInt();
				answer = "";

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

			for(int i =0; i<shuffleTimes; i++){
				shuffleBegin = scan.nextInt();
				answer = "";

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

			for(int i =0; i<shuffleTimes; i++){
				shuffleBegin = scan.nextInt();
				answer = "";

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

			for(int i =0; i<shuffleTimes; i++){
				shuffleBegin = scan.nextInt();
				answer = "";

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

			for(int i =0; i<shuffleTimes; i++){
				shuffleBegin = scan.nextInt();
				answer = "";

				for(int j=0; j<(targetLength - shuffleBegin) ; j++){
					answer = answer + targetChar[j + shuffleBegin];
				}
				for(int j=0; j<shuffleBegin; j++){
					answer = answer + targetChar[j];
				}
				targetChar = answer.toCharArray();
			}
			System.out.println(answer);
		} 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 int shuffleBegin = 0; shuffleBegin 0 for(int i =0; i<shuffleTimes; i++){
				shuffleBegin = scan.nextInt();
				answer = "";

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

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

				for(int j=0; j<(targetLength - shuffleBegin) ; j++){
					answer = answer + targetChar[j + shuffleBegin];
				}
				for(int j=0; j<shuffleBegin; j++){
					answer = answer + targetChar[j];
				}
				targetChar = answer.toCharArray();
			} shuffleBegin = scan.nextInt() shuffleBegin scan.nextInt() scan.nextInt scan answer = "" answer "" for(int j=0; j<(targetLength - shuffleBegin) ; j++){
					answer = answer + targetChar[j + shuffleBegin];
				} int j=0; int j=0; j 0 j<(targetLength - shuffleBegin) j (targetLength - shuffleBegin) targetLength shuffleBegin j++ j++ j {
					answer = answer + targetChar[j + shuffleBegin];
				} {
					answer = answer + targetChar[j + shuffleBegin];
				} answer = answer + targetChar[j + shuffleBegin] answer answer + targetChar[j + shuffleBegin] answer targetChar[j + shuffleBegin] targetChar j + shuffleBegin j shuffleBegin for(int j=0; j<shuffleBegin; j++){
					answer = answer + targetChar[j];
				} int j=0; int j=0; j 0 j<shuffleBegin j shuffleBegin j++ j++ j {
					answer = answer + targetChar[j];
				} {
					answer = answer + targetChar[j];
				} answer = answer + targetChar[j] answer answer + targetChar[j] answer targetChar[j] targetChar j targetChar = answer.toCharArray() targetChar answer.toCharArray() answer.toCharArray answer System.out.println(answer) System.out.println System.out System System.out answer 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 answer = "";
		String temp = "";
		
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			int shuffleTimes = scan.nextInt();
			int shuffleBegin = 0;

			for(int i =0; i<shuffleTimes; i++){
				shuffleBegin = scan.nextInt();
				answer = "";

				for(int j=0; j<(targetLength - shuffleBegin) ; j++){
					answer = answer + targetChar[j + shuffleBegin];
				}
				for(int j=0; j<shuffleBegin; j++){
					answer = answer + targetChar[j];
				}
				targetChar = answer.toCharArray();
			}
			System.out.println(answer);
		}
	}
}