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(????????????????????°);
} 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 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(????????????????????°);
} 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(????????????????????°); main {

		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());

		}

	} BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) 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());

		} 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());

		} String alphabet_cards = input.readLine(); alphabet_cards input.readLine() input.readLine input if (alphabet_cards.equals("-")) {

				break;
			} alphabet_cards.equals("-") alphabet_cards.equals alphabet_cards "-" {

				break;
			} break; String shuffle_num = input.readLine(); shuffle_num input.readLine() input.readLine input int shuffle_times = Integer.parseInt(shuffle_num); shuffle_times Integer.parseInt(shuffle_num) Integer.parseInt Integer shuffle_num StringBuilder shuffle_before_cards = new StringBuilder(alphabet_cards); 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);

			} int cards_spot = 0; int cards_spot = 0; cards_spot 0 cards_spot < shuffle_times cards_spot shuffle_times cards_spot++ cards_spot++ 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);

			} {

				//??????????????§????????£??????????????????
				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);

			} String shuffle_spot = input.readLine(); shuffle_spot input.readLine() input.readLine input int shuffle_cards = Integer.parseInt(shuffle_spot); shuffle_cards Integer.parseInt(shuffle_spot) Integer.parseInt Integer shuffle_spot String extracted_cards = shuffle_before_cards.substring(0, shuffle_cards); extracted_cards shuffle_before_cards.substring(0, shuffle_cards) shuffle_before_cards.substring shuffle_before_cards 0 shuffle_cards shuffle_before_cards.delete(0, shuffle_cards) shuffle_before_cards.delete shuffle_before_cards 0 shuffle_cards shuffle_before_cards = shuffle_before_cards.append(extracted_cards) shuffle_before_cards shuffle_before_cards.append(extracted_cards) shuffle_before_cards.append shuffle_before_cards extracted_cards System.out.println(shuffle_before_cards.toString()) System.out.println System.out System System.out shuffle_before_cards.toString() shuffle_before_cards.toString shuffle_before_cards String[] args args 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(????????????????????°);
} 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(????????????????????°);
} 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 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(????????????????????°);
}