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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String x = "";
		try {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			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) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String x = "";
		try {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String x = "";
		try {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String x = "";
		try {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String x = ""; x "" try {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} NumberFormatException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} IOException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			} (x = in.readLine()).equals("-") == false (x = in.readLine()).equals("-") (x = in.readLine()).equals (x = in.readLine()) x in.readLine() in.readLine in "-" false {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			} String word = x; word x int n = Integer.parseInt(in.readLine()); n Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				} {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				} int w = Integer.parseInt(in.readLine()); w Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in word = word.substring(w, (word.length())) + word.substring(0, w) word word.substring(w, (word.length())) + word.substring(0, w) word.substring(w, (word.length())) word.substring word w (word.length()) word.length word word.substring(0, w) word.substring word 0 w System.out.println(word) System.out.println System.out System System.out word String[] args args public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String x = "";
		try {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String x = "";
		try {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String x = "";
		try {
			while ((x = in.readLine()).equals("-") == false) {
				String word = x;
				int n = Integer.parseInt(in.readLine());
				
				for (int i = 0; i < n; i++) {
					int w = Integer.parseInt(in.readLine());
					word = word.substring(w, (word.length())) + word.substring(0, w);
				}
				System.out.println(word);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}