
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	//	System.out.println("?????£??????????????????????????????????????????-?????\???");

		List<String> list = new ArrayList<String>();

		while(sc.hasNext()) {


			String strCards = sc.nextLine();
			String[] arrayCards = new String[strCards.length()];

			if(strCards.equals("-")) {
		//		System.out.println("???????????????");
				break;
			}else {

				//??????????????\??????????????´??????????§£??????????´??????????
				for(int i = 0; i < strCards.length(); i++) {
					arrayCards[i] = strCards.substring(i, i+1);
				}

		//		for(String s : arrayCards) {
		//			System.out.println("?????£???????????? : "+s);
		//		}

				//???????????£???????????????????±???????
		//		System.out.println("???????????£?????????????????????");

				String strH = sc.nextLine();
				int intH = Integer.parseInt(strH);

				//int intH = sc.nextInt();
				for(int i = 0; i < intH; i++) {
		//			System.out.println("?????£?????????"+ (i+1) +"??????");
		//			System.out.println("?????????h??????????????????????????£?????????????????????");


					String strInputNum = sc.nextLine();
					int inputNum = Integer.parseInt(strInputNum);

					//int inputNum = sc.nextInt();
					arrayCards = shuffle(inputNum, strCards, arrayCards);
				}

		//		System.out.println("?????£???????????????");


			//	for(String s : arrayCards) {
			//		System.out.println("?????£???????????? : "+s);
			//	}

				StringBuffer buf = new StringBuffer();

				for(int i = 0; i < arrayCards.length; i++) {
					buf.append(arrayCards[i]);
				}
				//?????£??????????????????????????????????????????
				String strBuf = buf.toString();

				list.add(strBuf);

		//		System.out.println("??°?????????????????§?????£??????????????????????????????????????????-?????\???");

			}
		}

		for(String s : list) {
			System.out.println(s);
		}

	}

	public static String[] shuffle(int intH, String strCards, String[] arrayCards) {

		String[] arrayOkibaBack = new String[intH];

		int aOFYousosu =  strCards.length() - intH;
		String[] arrayOkibaFront = new String[aOFYousosu];

		//????????????????????????????????????
		for(int i = 0; i < intH; i++) {
			arrayOkibaBack[i] = arrayCards[i];
		}

		//????????????????????????????????????
		int Count = 0;
		for(int i = intH; i < strCards.length();i++) {
			arrayOkibaFront[Count] = arrayCards[i];
			Count++;
		}
		//?????£???????????????????????????????????\????????????
		for(int i = 0; i < strCards.length(); i++) {
			if(i < arrayOkibaFront.length) {
				arrayCards[i] = arrayOkibaFront[i];
			}
			else {
				arrayCards[i] = arrayOkibaBack[i - (arrayOkibaFront.length)];
			}
		}

		return arrayCards;

	}
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz