import java.io.IOException;
import java.util.Scanner;
public class Main {

	private static String q[]; // pueue
	private static int num; // カードの枚数
	private static int times; // シャッフルの回数
	private static String result; // 結果
	private static int front;
	private static int rear;

	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		while(true) {
			String s = sc.next();
			if(s.equals("-")) {
				break;
			}

			String[] array = s.split("");
			num = array.length;
			q = new String[num+1];
			result = "";
			front = 0;
			rear = num;

			for(int i=0;i<num;i++) {
				q[i] = array[i];
			}
			times = sc.nextInt();
			for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			}

			for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			}
			System.out.println(result);
		}

		sc.close();
	}

	public static int next(int a) {
		return (a + 1) % (num+1);
	}

	public static void enqueue(String x) {
		q[rear] = x;
		rear = next(rear);
	}

	public static String dequeue() {
		String x = q[front];
		q[front] = null;
		front = next(front);
		return x;
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {

	private static String q[]; // pueue
	private static int num; // カードの枚数
	private static int times; // シャッフルの回数
	private static String result; // 結果
	private static int front;
	private static int rear;

	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		while(true) {
			String s = sc.next();
			if(s.equals("-")) {
				break;
			}

			String[] array = s.split("");
			num = array.length;
			q = new String[num+1];
			result = "";
			front = 0;
			rear = num;

			for(int i=0;i<num;i++) {
				q[i] = array[i];
			}
			times = sc.nextInt();
			for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			}

			for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			}
			System.out.println(result);
		}

		sc.close();
	}

	public static int next(int a) {
		return (a + 1) % (num+1);
	}

	public static void enqueue(String x) {
		q[rear] = x;
		rear = next(rear);
	}

	public static String dequeue() {
		String x = q[front];
		q[front] = null;
		front = next(front);
		return x;
	}
} Main private static String q[]; // pueue q private static int num; // カードの枚数 num private static int times; // シャッフルの回数 times private static String result; // 結果 result private static int front; front private static int rear; rear public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		while(true) {
			String s = sc.next();
			if(s.equals("-")) {
				break;
			}

			String[] array = s.split("");
			num = array.length;
			q = new String[num+1];
			result = "";
			front = 0;
			rear = num;

			for(int i=0;i<num;i++) {
				q[i] = array[i];
			}
			times = sc.nextInt();
			for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			}

			for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			}
			System.out.println(result);
		}

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		while(true) {
			String s = sc.next();
			if(s.equals("-")) {
				break;
			}

			String[] array = s.split("");
			num = array.length;
			q = new String[num+1];
			result = "";
			front = 0;
			rear = num;

			for(int i=0;i<num;i++) {
				q[i] = array[i];
			}
			times = sc.nextInt();
			for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			}

			for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			}
			System.out.println(result);
		}

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			String s = sc.next();
			if(s.equals("-")) {
				break;
			}

			String[] array = s.split("");
			num = array.length;
			q = new String[num+1];
			result = "";
			front = 0;
			rear = num;

			for(int i=0;i<num;i++) {
				q[i] = array[i];
			}
			times = sc.nextInt();
			for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			}

			for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			}
			System.out.println(result);
		} true {
			String s = sc.next();
			if(s.equals("-")) {
				break;
			}

			String[] array = s.split("");
			num = array.length;
			q = new String[num+1];
			result = "";
			front = 0;
			rear = num;

			for(int i=0;i<num;i++) {
				q[i] = array[i];
			}
			times = sc.nextInt();
			for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			}

			for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			}
			System.out.println(result);
		} String s = sc.next(); s sc.next() sc.next sc if(s.equals("-")) {
				break;
			} s.equals("-") s.equals s "-" {
				break;
			} break; String[] array = s.split(""); array s.split("") s.split s "" num = array.length num array.length array array.length q = new String[num+1] q new String[num+1] num+1 num 1 result = "" result "" front = 0 front 0 rear = num rear num for(int i=0;i<num;i++) {
				q[i] = array[i];
			} int i=0; int i=0; i 0 i<num i num i++ i++ i {
				q[i] = array[i];
			} {
				q[i] = array[i];
			} q[i] = array[i] q[i] q i array[i] array i times = sc.nextInt() times sc.nextInt() sc.nextInt sc for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			} int i=0; int i=0; i 0 i<times i times i++ i++ i {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			} {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			} int tmp = sc.nextInt(); tmp sc.nextInt() sc.nextInt sc for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				} int j=0; int j=0; j 0 j<tmp j tmp j++ j++ j {
					enqueue(dequeue());
				} {
					enqueue(dequeue());
				} enqueue(dequeue()) enqueue dequeue() dequeue for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			} int i=front; int i=front; i front i!=rear i rear i=next(i) i=next(i) i next(i) next i {
				result += q[i];
			} {
				result += q[i];
			} result += q[i] result q[i] q i System.out.println(result) System.out.println System.out System System.out result sc.close() sc.close sc String[] args args public static int next(int a) {
		return (a + 1) % (num+1);
	} next {
		return (a + 1) % (num+1);
	} return (a + 1) % (num+1); (a + 1) % (num+1) (a + 1) a 1 (num+1) num 1 int a a public static void enqueue(String x) {
		q[rear] = x;
		rear = next(rear);
	} enqueue {
		q[rear] = x;
		rear = next(rear);
	} q[rear] = x q[rear] q rear x rear = next(rear) rear next(rear) next rear String x x public static String dequeue() {
		String x = q[front];
		q[front] = null;
		front = next(front);
		return x;
	} dequeue {
		String x = q[front];
		q[front] = null;
		front = next(front);
		return x;
	} String x = q[front]; x q[front] q front q[front] = null q[front] q front null front = next(front) front next(front) next front return x; x public class Main {

	private static String q[]; // pueue
	private static int num; // カードの枚数
	private static int times; // シャッフルの回数
	private static String result; // 結果
	private static int front;
	private static int rear;

	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		while(true) {
			String s = sc.next();
			if(s.equals("-")) {
				break;
			}

			String[] array = s.split("");
			num = array.length;
			q = new String[num+1];
			result = "";
			front = 0;
			rear = num;

			for(int i=0;i<num;i++) {
				q[i] = array[i];
			}
			times = sc.nextInt();
			for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			}

			for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			}
			System.out.println(result);
		}

		sc.close();
	}

	public static int next(int a) {
		return (a + 1) % (num+1);
	}

	public static void enqueue(String x) {
		q[rear] = x;
		rear = next(rear);
	}

	public static String dequeue() {
		String x = q[front];
		q[front] = null;
		front = next(front);
		return x;
	}
} public class Main {

	private static String q[]; // pueue
	private static int num; // カードの枚数
	private static int times; // シャッフルの回数
	private static String result; // 結果
	private static int front;
	private static int rear;

	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		while(true) {
			String s = sc.next();
			if(s.equals("-")) {
				break;
			}

			String[] array = s.split("");
			num = array.length;
			q = new String[num+1];
			result = "";
			front = 0;
			rear = num;

			for(int i=0;i<num;i++) {
				q[i] = array[i];
			}
			times = sc.nextInt();
			for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			}

			for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			}
			System.out.println(result);
		}

		sc.close();
	}

	public static int next(int a) {
		return (a + 1) % (num+1);
	}

	public static void enqueue(String x) {
		q[rear] = x;
		rear = next(rear);
	}

	public static String dequeue() {
		String x = q[front];
		q[front] = null;
		front = next(front);
		return x;
	}
} Main
import java.io.IOException;
import java.util.Scanner;
public class Main {

	private static String q[]; // pueue
	private static int num; // カードの枚数
	private static int times; // シャッフルの回数
	private static String result; // 結果
	private static int front;
	private static int rear;

	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		while(true) {
			String s = sc.next();
			if(s.equals("-")) {
				break;
			}

			String[] array = s.split("");
			num = array.length;
			q = new String[num+1];
			result = "";
			front = 0;
			rear = num;

			for(int i=0;i<num;i++) {
				q[i] = array[i];
			}
			times = sc.nextInt();
			for(int i=0;i<times;i++) {
				int tmp = sc.nextInt();
				for(int j=0;j<tmp;j++) {
					enqueue(dequeue());
				}
			}

			for(int i=front;i!=rear;i=next(i)) {
				result += q[i];
			}
			System.out.println(result);
		}

		sc.close();
	}

	public static int next(int a) {
		return (a + 1) % (num+1);
	}

	public static void enqueue(String x) {
		q[rear] = x;
		rear = next(rear);
	}

	public static String dequeue() {
		String x = q[front];
		q[front] = null;
		front = next(front);
		return x;
	}
}
