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

public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String cards;
			String str;
			int h;
			String begin;
			String end;
			while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			}
				
		} 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 void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String cards;
			String str;
			int h;
			String begin;
			String end;
			while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			}
				
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String cards;
			String str;
			int h;
			String begin;
			String end;
			while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			}
				
		} catch (IOException e) {
			e.printStackTrace();
		}
	} main {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String cards;
			String str;
			int h;
			String begin;
			String end;
			while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			}
				
		} catch (IOException e) {
			e.printStackTrace();
		}
	} try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String cards;
			String str;
			int h;
			String begin;
			String end;
			while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			}
				
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String cards;
			String str;
			int h;
			String begin;
			String end;
			while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			}
				
		} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String cards; cards String str; str int h; h String begin; begin String end; end while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			} !(cards = reader.readLine()).equals("-") (cards = reader.readLine()).equals("-") (cards = reader.readLine()).equals (cards = reader.readLine()) cards reader.readLine() reader.readLine reader "-" {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			} str = reader.readLine() str reader.readLine() reader.readLine reader int m = Integer.parseInt(str); m Integer.parseInt(str) Integer.parseInt Integer str for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				} {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				} str = reader.readLine() str reader.readLine() reader.readLine reader h = Integer.parseInt(str) h Integer.parseInt(str) Integer.parseInt Integer str begin = cards.substring(0, h) begin cards.substring(0, h) cards.substring cards 0 h end = cards.substring(h, cards.length()) end cards.substring(h, cards.length()) cards.substring cards h cards.length() cards.length cards cards = end.concat(begin) cards end.concat(begin) end.concat end begin System.out.println(cards) System.out.println System.out System System.out cards String[] args args public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String cards;
			String str;
			int h;
			String begin;
			String end;
			while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			}
				
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String cards;
			String str;
			int h;
			String begin;
			String end;
			while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			}
				
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String cards;
			String str;
			int h;
			String begin;
			String end;
			while (!(cards = reader.readLine()).equals("-")) {
				str = reader.readLine(); 
				int m = Integer.parseInt(str);
				for (int i = 0; i < m; i++) {
					str = reader.readLine();
					h = Integer.parseInt(str);
					begin = cards.substring(0, h);
					end = cards.substring(h, cards.length());
					cards = end.concat(begin);
				}
				System.out.println(cards);
			}
				
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}