

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[]) throws IOException {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();
		String str = "";
		int num, number;
		num = 0;// ?????°
		char c;

		// ??????????????\???????????????????????????
		// List<String> list = new ArrayList<String>();

		// ???????????????????????§??????
		while (true) {
			// StringBuilder?????\??????
			sb.append(scan.next());
			// System.out.println("??????????§?");
			if (new String(sb).equals("-")) {
				break;
			}

			// ?????°???input
			num = scan.nextInt();
			// ?????°??????????????????
			for (int count2 = 0; count2 < num; count2++) {
				// ?????£??????????????°
				number = scan.nextInt();
				// ?????£??????????????? c = sb.charAt(0);

				for (int count3 = 0; count3 < number; count3++) {
					// ?????£??????????????°???????????????????????????????°?????????£?????????
					// sb?????????????¶???????????????????????????£?????????
					// ??????????????????c?????£??\
					c = sb.charAt(0);
					// ????????????????????????
					sb.delete(0, 1);
					// c??????????°??????????
					sb.append(String.valueOf(c));
				}

			}

			sb2.append(new String(sb));
			sb2.append("\n");
			// sb?????????
			sb.setLength(0);

		}
		sb2.deleteCharAt(sb2.length() - 1);
		System.out.println(new String(sb2));
	}
}
/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