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

public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(true){
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		}
	}
} 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 {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(true){
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		}
	}
} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(true){
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		}
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(true){
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str while(true){
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		} true {
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		} str = br.readLine() str br.readLine() br.readLine br if(str.equals("-")){
				break;
			} str.equals("-") str.equals str "-" {
				break;
			} break; StringBuffer sb = new StringBuffer(); sb new StringBuffer() sb.append(str) sb.append sb str int count = Integer.parseInt(br.readLine()); count Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			} int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			} {
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			} int indexNum = Integer.parseInt(br.readLine()); indexNum Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br sb.append(sb.substring(0, indexNum)) sb.append sb sb.substring(0, indexNum) sb.substring sb 0 indexNum sb.delete(0, indexNum) sb.delete sb 0 indexNum System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb String[] args args public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(true){
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		}
	}
} public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(true){
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		}
	}
} Main

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

public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(true){
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		}
	}
}