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

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static boolean isNumber (String s) {
		try {
			Integer.parseInt(s);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static boolean isNumber (String s) {
		try {
			Integer.parseInt(s);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
} Main public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	} main {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	} try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} Exception e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) StringBuilder answer = new StringBuilder(); answer new StringBuilder() String lb = System.getProperty("line.separator"); lb System.getProperty("line.separator") System.getProperty System "line.separator" String str = input.readLine(); str input.readLine() input.readLine input int m; m int h; h while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			} !str.equals("-") str.equals("-") str.equals str "-" {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			} m = Integer.parseInt(input.readLine()) m Integer.parseInt(input.readLine()) Integer.parseInt Integer input.readLine() input.readLine input for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				} {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				} h = Integer.parseInt(input.readLine()) h Integer.parseInt(input.readLine()) Integer.parseInt Integer input.readLine() input.readLine input str = (str.substring(h, str.length()) + str.substring(0, h)) str (str.substring(h, str.length()) + str.substring(0, h)) str.substring(h, str.length()) str.substring str h str.length() str.length str str.substring(0, h) str.substring str 0 h answer.append(str).append(lb) answer.append(str).append answer.append(str) answer.append answer str lb str = input.readLine() str input.readLine() input.readLine input System.out.print(answer.toString()) System.out.print System.out System System.out answer.toString() answer.toString answer String[] args args public static boolean isNumber (String s) {
		try {
			Integer.parseInt(s);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	} isNumber {
		try {
			Integer.parseInt(s);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	} try {
			Integer.parseInt(s);
			return true;
		} catch (NumberFormatException e) {
			return false;
		} catch (NumberFormatException e) {
			return false;
		} NumberFormatException e {
			return false;
		} return false; false {
			Integer.parseInt(s);
			return true;
		} Integer.parseInt(s) Integer.parseInt Integer s return true; true String s s public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static boolean isNumber (String s) {
		try {
			Integer.parseInt(s);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
} public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static boolean isNumber (String s) {
		try {
			Integer.parseInt(s);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static boolean isNumber (String s) {
		try {
			Integer.parseInt(s);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
}