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

public class Main{

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

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

		// ?????£?????????????????????????????????????????????
		//String shuffle_strings = "";

		while (true) {

			// ??????????????°??¢??????????????????????????\???
			String alphabet_cards = input.readLine();

			//-?????\?????§??????
			if (alphabet_cards.equals("-")) {

				break;
			}

			String shuffle_num = input.readLine();

			// ?????£?????????????????°
			int shuffle_times = Integer.parseInt(shuffle_num);

			StringBuilder shuffle_before_cards = new StringBuilder(alphabet_cards);

			// ?????£?????????????????°????????????????????£?????????
			for (int cards_spot = 0; cards_spot < shuffle_times; cards_spot++) {

				//??????????????§????????£??????????????????
				String shuffle_spot = input.readLine();

				int shuffle_cards = Integer.parseInt(shuffle_spot);

				// ??\??????????????¢???????????????????????????????????????shuffle_cards???????????§?????????
				String extracted_cards = shuffle_before_cards.substring(0, shuffle_cards);

				//???????????\???????????????????????\????????????alphabet_cards??????extracted_cards????¶????
				shuffle_before_cards.delete(0, shuffle_cards);

				//???????????\??????????????????,????°????extracted_cards????¶????
				shuffle_before_cards = shuffle_before_cards.append(extracted_cards);

			}

			System.out.println(shuffle_before_cards.toString());

		}

	}//StringBuilder ?????° = new StringBuilder(????????????????????°);
}
/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