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

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

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

		String first;
		char table[] = new char[20000];

		int M,h,left,right;


		try {

			while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			}


		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} 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 final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

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

		String first;
		char table[] = new char[20000];

		int M,h,left,right;


		try {

			while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			}


		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main public static final int BIG_NUM  = 2000000000; BIG_NUM 2000000000 public static final int MOD  = 1000000007; MOD 1000000007 public static void main(String[] args) {

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

		String first;
		char table[] = new char[20000];

		int M,h,left,right;


		try {

			while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			}


		} catch (IOException e) {
			e.printStackTrace();
		}
	} main {

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

		String first;
		char table[] = new char[20000];

		int M,h,left,right;


		try {

			while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			}


		} catch (IOException e) {
			e.printStackTrace();
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String first; first char table[] = new char[20000]; table new char[20000] 20000 int M M h h left left right; right try {

			while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			}


		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {

			while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			}


		} while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			} !(first = br.readLine()).equals("-") (first = br.readLine()).equals("-") (first = br.readLine()).equals (first = br.readLine()) first br.readLine() br.readLine br "-" {

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			} for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				} int i = 0; int i = 0; i 0 i < first.length() i first.length() first.length first i++ i++ i {
					table[i] = first.charAt(i);
				} {
					table[i] = first.charAt(i);
				} table[i] = first.charAt(i) table[i] table i first.charAt(i) first.charAt first i left = 0 left 0 right = first.length()-1 right first.length()-1 first.length() first.length first 1 M = Integer.parseInt(br.readLine()) M Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				} int loop = 0; int loop = 0; loop 0 loop < M loop M loop++ loop++ loop {
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				} {
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				} h = Integer.parseInt(br.readLine()) h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					} int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
						table[right+1+i] = table[left+i];
					} {
						table[right+1+i] = table[left+i];
					} table[right+1+i] = table[left+i] table[right+1+i] table right+1+i right+1+i right 1 i table[left+i] table left+i left i left += h left h right += h right h for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				} int i = left; int i = left; i left i <= right i right i++ i++ i {
					System.out.printf("%c", table[i]);
				} {
					System.out.printf("%c", table[i]);
				} System.out.printf("%c", table[i]) System.out.printf System.out System System.out "%c" table[i] table i System.out.printf("\n") System.out.printf System.out System System.out "\n" String[] args args public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

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

		String first;
		char table[] = new char[20000];

		int M,h,left,right;


		try {

			while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			}


		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

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

		String first;
		char table[] = new char[20000];

		int M,h,left,right;


		try {

			while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			}


		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

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

		String first;
		char table[] = new char[20000];

		int M,h,left,right;


		try {

			while(!(first = br.readLine()).equals("-")){

				for(int i = 0; i < first.length(); i++){
					table[i] = first.charAt(i);
				}

				left = 0;
				right = first.length()-1;

				M = Integer.parseInt(br.readLine());

				for(int loop = 0; loop < M; loop++){
					h = Integer.parseInt(br.readLine());

					for(int i = 0; i < h; i++){
						table[right+1+i] = table[left+i];
					}
					left += h;
					right += h;
				}

				for(int i = left; i <= right; i++){
					System.out.printf("%c", table[i]);
				}
				System.out.printf("\n");
			}


		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
