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


public class Main{

	public static void main(String[] args) throws IOException{
		// TODO ?????????????????????????????????????????????

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		String strLine = null;
		while(true){
			//??????????????????
			strLine = insBR.readLine();
			//?????¬???????????¶
			if("-".equals(strLine)){
				break;
			}
			//?????£??????????????°??????
			String strNum =insBR.readLine();
			int m = Integer.parseInt(strNum);

			for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			}
			System.out.println(strLine);

		}


	}
} 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{
		// TODO ?????????????????????????????????????????????

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		String strLine = null;
		while(true){
			//??????????????????
			strLine = insBR.readLine();
			//?????¬???????????¶
			if("-".equals(strLine)){
				break;
			}
			//?????£??????????????°??????
			String strNum =insBR.readLine();
			int m = Integer.parseInt(strNum);

			for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			}
			System.out.println(strLine);

		}


	}
} Main public static void main(String[] args) throws IOException{
		// TODO ?????????????????????????????????????????????

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		String strLine = null;
		while(true){
			//??????????????????
			strLine = insBR.readLine();
			//?????¬???????????¶
			if("-".equals(strLine)){
				break;
			}
			//?????£??????????????°??????
			String strNum =insBR.readLine();
			int m = Integer.parseInt(strNum);

			for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			}
			System.out.println(strLine);

		}


	} main {
		// TODO ?????????????????????????????????????????????

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		String strLine = null;
		while(true){
			//??????????????????
			strLine = insBR.readLine();
			//?????¬???????????¶
			if("-".equals(strLine)){
				break;
			}
			//?????£??????????????°??????
			String strNum =insBR.readLine();
			int m = Integer.parseInt(strNum);

			for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			}
			System.out.println(strLine);

		}


	} BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in)); insBR new BufferedReader(new InputStreamReader(System.in)) String strLine = null; strLine null while(true){
			//??????????????????
			strLine = insBR.readLine();
			//?????¬???????????¶
			if("-".equals(strLine)){
				break;
			}
			//?????£??????????????°??????
			String strNum =insBR.readLine();
			int m = Integer.parseInt(strNum);

			for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			}
			System.out.println(strLine);

		} true {
			//??????????????????
			strLine = insBR.readLine();
			//?????¬???????????¶
			if("-".equals(strLine)){
				break;
			}
			//?????£??????????????°??????
			String strNum =insBR.readLine();
			int m = Integer.parseInt(strNum);

			for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			}
			System.out.println(strLine);

		} strLine = insBR.readLine() strLine insBR.readLine() insBR.readLine insBR if("-".equals(strLine)){
				break;
			} "-".equals(strLine) "-".equals "-" strLine {
				break;
			} break; String strNum =insBR.readLine(); strNum insBR.readLine() insBR.readLine insBR int m = Integer.parseInt(strNum); m Integer.parseInt(strNum) Integer.parseInt Integer strNum for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			} {
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			} String strH = insBR.readLine(); strH insBR.readLine() insBR.readLine insBR int h = Integer.parseInt(strH); h Integer.parseInt(strH) Integer.parseInt Integer strH String strCutLine = strLine.substring(0,h); strCutLine strLine.substring(0,h) strLine.substring strLine 0 h String strTemp = strLine.substring(h,strLine.length()); strTemp strLine.substring(h,strLine.length()) strLine.substring strLine h strLine.length() strLine.length strLine strLine = strTemp + strCutLine strLine strTemp + strCutLine strTemp strCutLine System.out.println(strLine) System.out.println System.out System System.out strLine String[] args args public class Main{

	public static void main(String[] args) throws IOException{
		// TODO ?????????????????????????????????????????????

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		String strLine = null;
		while(true){
			//??????????????????
			strLine = insBR.readLine();
			//?????¬???????????¶
			if("-".equals(strLine)){
				break;
			}
			//?????£??????????????°??????
			String strNum =insBR.readLine();
			int m = Integer.parseInt(strNum);

			for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			}
			System.out.println(strLine);

		}


	}
} public class Main{

	public static void main(String[] args) throws IOException{
		// TODO ?????????????????????????????????????????????

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		String strLine = null;
		while(true){
			//??????????????????
			strLine = insBR.readLine();
			//?????¬???????????¶
			if("-".equals(strLine)){
				break;
			}
			//?????£??????????????°??????
			String strNum =insBR.readLine();
			int m = Integer.parseInt(strNum);

			for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			}
			System.out.println(strLine);

		}


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


public class Main{

	public static void main(String[] args) throws IOException{
		// TODO ?????????????????????????????????????????????

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		String strLine = null;
		while(true){
			//??????????????????
			strLine = insBR.readLine();
			//?????¬???????????¶
			if("-".equals(strLine)){
				break;
			}
			//?????£??????????????°??????
			String strNum =insBR.readLine();
			int m = Integer.parseInt(strNum);

			for(int i = 0; i < m; i++){
				//????????????????????°?????????
				String strH = insBR.readLine();
				int h = Integer.parseInt(strH);

				//?????????????????????
				String strCutLine = strLine.substring(0,h);
				String strTemp = strLine.substring(h,strLine.length());
				//??£???
				strLine = strTemp + strCutLine;
			}
			System.out.println(strLine);

		}


	}
}