import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String cards = sc.next();
			if(cards.equals("-")) {
				break;
			}
			int m = sc.nextInt();
for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
}
System.out.println(cards);
		}
	}
}
 import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String cards = sc.next();
			if(cards.equals("-")) {
				break;
			}
			int m = sc.nextInt();
for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
}
System.out.println(cards);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String cards = sc.next();
			if(cards.equals("-")) {
				break;
			}
			int m = sc.nextInt();
for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
}
System.out.println(cards);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String cards = sc.next();
			if(cards.equals("-")) {
				break;
			}
			int m = sc.nextInt();
for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
}
System.out.println(cards);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			String cards = sc.next();
			if(cards.equals("-")) {
				break;
			}
			int m = sc.nextInt();
for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
}
System.out.println(cards);
		} true {
			String cards = sc.next();
			if(cards.equals("-")) {
				break;
			}
			int m = sc.nextInt();
for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
}
System.out.println(cards);
		} String cards = sc.next(); cards sc.next() sc.next sc if(cards.equals("-")) {
				break;
			} cards.equals("-") cards.equals cards "-" {
				break;
			} break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
} int i=0; int i=0; i 0 i<m i m i++ i++ i {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
} {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
} int count=sc.nextInt(); count sc.nextInt() sc.nextInt sc String move=cards.substring(0,count); move cards.substring(0,count) cards.substring cards 0 count String move2=cards.substring(count); move2 cards.substring(count) cards.substring cards count cards=move2+move cards move2+move move2 move 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) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String cards = sc.next();
			if(cards.equals("-")) {
				break;
			}
			int m = sc.nextInt();
for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
}
System.out.println(cards);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String cards = sc.next();
			if(cards.equals("-")) {
				break;
			}
			int m = sc.nextInt();
for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
}
System.out.println(cards);
		}
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String cards = sc.next();
			if(cards.equals("-")) {
				break;
			}
			int m = sc.nextInt();
for(int i=0;i<m;i++) {
	int count=sc.nextInt();
	String move=cards.substring(0,count);
	String move2=cards.substring(count);
	cards=move2+move;
}
System.out.println(cards);
		}
	}
}

