import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String card = "";
		int h;
		int m;
		ArrayList<String> al = new ArrayList<>();
		int cnt = 0;
		while(!(card.equals("-"))) {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		}
		for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		}

	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String card = "";
		int h;
		int m;
		ArrayList<String> al = new ArrayList<>();
		int cnt = 0;
		while(!(card.equals("-"))) {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		}
		for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		}

	}
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String card = "";
		int h;
		int m;
		ArrayList<String> al = new ArrayList<>();
		int cnt = 0;
		while(!(card.equals("-"))) {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		}
		for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		}

	} main {
		
		Scanner sc = new Scanner(System.in);
		
		String card = "";
		int h;
		int m;
		ArrayList<String> al = new ArrayList<>();
		int cnt = 0;
		while(!(card.equals("-"))) {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		}
		for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String card = ""; card "" int h; h int m; m ArrayList<String> al = new ArrayList<>(); al new ArrayList<>() int cnt = 0; cnt 0 while(!(card.equals("-"))) {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		} !(card.equals("-")) (card.equals("-")) card.equals card "-" {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		} card = sc.next() card sc.next() sc.next sc char[] cardArray = card.toCharArray(); cardArray card.toCharArray() card.toCharArray card if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			} card.equals("-") card.equals card "-" {
				break;
			} break; {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			} m = sc.nextInt() m sc.nextInt() sc.nextInt sc for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				} {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				} h = sc.nextInt() h sc.nextInt() sc.nextInt sc char[] tmp = new char[h]; tmp new char[h] h for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					} int j = 0; int j = 0; j 0 j < h j h j++ j++ j {
						tmp[j] = cardArray[j];
					} {
						tmp[j] = cardArray[j];
					} tmp[j] = cardArray[j] tmp[j] tmp j cardArray[j] cardArray j for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					} int k = 0; int k = 0; k 0 k < cardArray.length - h k cardArray.length - h cardArray.length cardArray cardArray.length h k++ k++ k {
						cardArray[k] = cardArray[k + h];
					} {
						cardArray[k] = cardArray[k + h];
					} cardArray[k] = cardArray[k + h] cardArray[k] cardArray k cardArray[k + h] cardArray k + h k h for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					} int l = 0; int l = 0; l 0 l < h l h l++ l++ l {
						cardArray[cardArray.length - h + l] = tmp[l];
					} {
						cardArray[cardArray.length - h + l] = tmp[l];
					} cardArray[cardArray.length - h + l] = tmp[l] cardArray[cardArray.length - h + l] cardArray cardArray.length - h + l cardArray.length - h cardArray.length cardArray cardArray.length h l tmp[l] tmp l cnt++ cnt al.add(String.valueOf(cardArray)) al.add al String.valueOf(cardArray) String.valueOf String cardArray for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		} int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
			System.out.println(al.get(i));
		} {
			System.out.println(al.get(i));
		} System.out.println(al.get(i)) System.out.println System.out System System.out al.get(i) al.get al i String[] args args public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String card = "";
		int h;
		int m;
		ArrayList<String> al = new ArrayList<>();
		int cnt = 0;
		while(!(card.equals("-"))) {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		}
		for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		}

	}
} public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String card = "";
		int h;
		int m;
		ArrayList<String> al = new ArrayList<>();
		int cnt = 0;
		while(!(card.equals("-"))) {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		}
		for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		}

	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String card = "";
		int h;
		int m;
		ArrayList<String> al = new ArrayList<>();
		int cnt = 0;
		while(!(card.equals("-"))) {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		}
		for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		}

	}
}