import java.util.Scanner;

//????????????

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//???????????????


		while (sc.hasNext()) {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		}

	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//???????????????


		while (sc.hasNext()) {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		}

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//???????????????


		while (sc.hasNext()) {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		}

	} main {
		Scanner sc = new Scanner(System.in);

		//???????????????


		while (sc.hasNext()) {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (sc.hasNext()) {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		} sc.hasNext() sc.hasNext sc {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		} String line1 = sc.next(); line1 sc.next() sc.next sc if(line1.equals("-")) {
				break;
			} line1.equals("-") line1.equals line1 "-" {
				break;
			} break; int count = sc.nextInt(); count sc.nextInt() sc.nextInt sc for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			} int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			} {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			} int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc StringBuilder sb = new StringBuilder(line1); sb new StringBuilder(line1) String cutLine = sb.substring(0 , num); cutLine sb.substring(0 , num) sb.substring sb 0 num line1 = sb.delete(0, num).toString() line1 sb.delete(0, num).toString() sb.delete(0, num).toString sb.delete(0, num) sb.delete sb 0 num line1 += cutLine line1 cutLine System.out.println(line1) System.out.println System.out System System.out line1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//???????????????


		while (sc.hasNext()) {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		}

	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//???????????????


		while (sc.hasNext()) {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		}

	}
} Main
import java.util.Scanner;

//????????????

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//???????????????


		while (sc.hasNext()) {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		}

	}
}