import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		String strCom = " ";
		BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
		while(true){
			String charaStr = br.readLine();
			if (charaStr.equals("-")){
				break;
			}

			int shuffleNum =Integer.parseInt(br.readLine());

			for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			}
			System.out.println(strCom);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		String strCom = " ";
		BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
		while(true){
			String charaStr = br.readLine();
			if (charaStr.equals("-")){
				break;
			}

			int shuffleNum =Integer.parseInt(br.readLine());

			for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			}
			System.out.println(strCom);
		}
	}
} Main public static void main(String[] args) throws IOException {
		String strCom = " ";
		BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
		while(true){
			String charaStr = br.readLine();
			if (charaStr.equals("-")){
				break;
			}

			int shuffleNum =Integer.parseInt(br.readLine());

			for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			}
			System.out.println(strCom);
		}
	} main {
		String strCom = " ";
		BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
		while(true){
			String charaStr = br.readLine();
			if (charaStr.equals("-")){
				break;
			}

			int shuffleNum =Integer.parseInt(br.readLine());

			for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			}
			System.out.println(strCom);
		}
	} String strCom = " "; strCom " " BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); br new BufferedReader (new InputStreamReader (System.in)) while(true){
			String charaStr = br.readLine();
			if (charaStr.equals("-")){
				break;
			}

			int shuffleNum =Integer.parseInt(br.readLine());

			for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			}
			System.out.println(strCom);
		} true {
			String charaStr = br.readLine();
			if (charaStr.equals("-")){
				break;
			}

			int shuffleNum =Integer.parseInt(br.readLine());

			for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			}
			System.out.println(strCom);
		} String charaStr = br.readLine(); charaStr br.readLine() br.readLine br if (charaStr.equals("-")){
				break;
			} charaStr.equals("-") charaStr.equals charaStr "-" {
				break;
			} break; int shuffleNum =Integer.parseInt(br.readLine()); shuffleNum Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			} int i = 0; int i = 0; i 0 i < shuffleNum i shuffleNum i++ i++ i {

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			} {

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			} int moveLength = Integer.parseInt(br.readLine()); moveLength Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br if (i == 0) {
					strCom = charaStr;
				} i == 0 i 0 {
					strCom = charaStr;
				} strCom = charaStr strCom charaStr String str1 = strCom.substring(0, moveLength); str1 strCom.substring(0, moveLength) strCom.substring strCom 0 moveLength String str2 = strCom.substring(moveLength, strCom.length()); str2 strCom.substring(moveLength, strCom.length()) strCom.substring strCom moveLength strCom.length() strCom.length strCom strCom = str2.concat(str1) strCom str2.concat(str1) str2.concat str2 str1 System.out.println(strCom) System.out.println System.out System System.out strCom String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		String strCom = " ";
		BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
		while(true){
			String charaStr = br.readLine();
			if (charaStr.equals("-")){
				break;
			}

			int shuffleNum =Integer.parseInt(br.readLine());

			for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			}
			System.out.println(strCom);
		}
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		String strCom = " ";
		BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
		while(true){
			String charaStr = br.readLine();
			if (charaStr.equals("-")){
				break;
			}

			int shuffleNum =Integer.parseInt(br.readLine());

			for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			}
			System.out.println(strCom);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		String strCom = " ";
		BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
		while(true){
			String charaStr = br.readLine();
			if (charaStr.equals("-")){
				break;
			}

			int shuffleNum =Integer.parseInt(br.readLine());

			for (int i = 0;i < shuffleNum;i++){

				int moveLength = Integer.parseInt(br.readLine());
				
				if (i == 0) {
					strCom = charaStr;
				}
				
				String str1 = strCom.substring(0, moveLength);
				String str2 = strCom.substring(moveLength, strCom.length());

				strCom = str2.concat(str1);
			}
			System.out.println(strCom);
		}
	}
}