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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String result ;
		int count = 0;

		while (true) {
			String str = br.readLine();
			if (str.equals("-")) {
				break;
			}

			String res = br.readLine();
			count = Integer.parseInt(res);
			int[] shuffle = new int[count];
			for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			}
			System.out.println(str);
		}
	}
} 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 br = new BufferedReader(new InputStreamReader(System.in));

		String result ;
		int count = 0;

		while (true) {
			String str = br.readLine();
			if (str.equals("-")) {
				break;
			}

			String res = br.readLine();
			count = Integer.parseInt(res);
			int[] shuffle = new int[count];
			for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			}
			System.out.println(str);
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String result ;
		int count = 0;

		while (true) {
			String str = br.readLine();
			if (str.equals("-")) {
				break;
			}

			String res = br.readLine();
			count = Integer.parseInt(res);
			int[] shuffle = new int[count];
			for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			}
			System.out.println(str);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String result ;
		int count = 0;

		while (true) {
			String str = br.readLine();
			if (str.equals("-")) {
				break;
			}

			String res = br.readLine();
			count = Integer.parseInt(res);
			int[] shuffle = new int[count];
			for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			}
			System.out.println(str);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String result ; result int count = 0; count 0 while (true) {
			String str = br.readLine();
			if (str.equals("-")) {
				break;
			}

			String res = br.readLine();
			count = Integer.parseInt(res);
			int[] shuffle = new int[count];
			for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			}
			System.out.println(str);
		} true {
			String str = br.readLine();
			if (str.equals("-")) {
				break;
			}

			String res = br.readLine();
			count = Integer.parseInt(res);
			int[] shuffle = new int[count];
			for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			}
			System.out.println(str);
		} String str = br.readLine(); str br.readLine() br.readLine br if (str.equals("-")) {
				break;
			} str.equals("-") str.equals str "-" {
				break;
			} break; String res = br.readLine(); res br.readLine() br.readLine br count = Integer.parseInt(res) count Integer.parseInt(res) Integer.parseInt Integer res int[] shuffle = new int[count]; shuffle new int[count] count for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			} int i =0; int i =0; i 0 i < count i count i++ i++ i {
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			} {
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			} String shuffler = br.readLine(); shuffler br.readLine() br.readLine br shuffle[i] = Integer.parseInt(shuffler) shuffle[i] shuffle i Integer.parseInt(shuffler) Integer.parseInt Integer shuffler result = str.substring(0,shuffle[i]) result str.substring(0,shuffle[i]) str.substring str 0 shuffle[i] shuffle i str += result str result str = str.substring(shuffle[i]) str str.substring(shuffle[i]) str.substring str shuffle[i] shuffle i System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String result ;
		int count = 0;

		while (true) {
			String str = br.readLine();
			if (str.equals("-")) {
				break;
			}

			String res = br.readLine();
			count = Integer.parseInt(res);
			int[] shuffle = new int[count];
			for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			}
			System.out.println(str);
		}
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String result ;
		int count = 0;

		while (true) {
			String str = br.readLine();
			if (str.equals("-")) {
				break;
			}

			String res = br.readLine();
			count = Integer.parseInt(res);
			int[] shuffle = new int[count];
			for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			}
			System.out.println(str);
		}
	}
} 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 br = new BufferedReader(new InputStreamReader(System.in));

		String result ;
		int count = 0;

		while (true) {
			String str = br.readLine();
			if (str.equals("-")) {
				break;
			}

			String res = br.readLine();
			count = Integer.parseInt(res);
			int[] shuffle = new int[count];
			for(int i =0; i < count; i++){
				String shuffler = br.readLine();
				shuffle[i] = Integer.parseInt(shuffler);
				result = str.substring(0,shuffle[i]);
				
				str += result;
				str = str.substring(shuffle[i]);
			}
			System.out.println(str);
		}
	}
}