import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String cards = s.next();
		while(!"-".equals(cards)){
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		}
	}
	public static void main(String args[]){
		new Main().run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String cards = s.next();
		while(!"-".equals(cards)){
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		}
	}
	public static void main(String args[]){
		new Main().run();
	}
} Main void run(){
		Scanner s = new Scanner(System.in);
		String cards = s.next();
		while(!"-".equals(cards)){
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		}
	} run {
		Scanner s = new Scanner(System.in);
		String cards = s.next();
		while(!"-".equals(cards)){
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		}
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) String cards = s.next(); cards s.next() s.next s while(!"-".equals(cards)){
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		} !"-".equals(cards) "-".equals(cards) "-".equals "-" cards {
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		} int num = s.nextInt(); num s.nextInt() s.nextInt s for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			} {
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			} int h = s.nextInt(); h s.nextInt() s.nextInt s String top = cards.substring(0,h); top cards.substring(0,h) cards.substring cards 0 h String under = cards.substring(h,cards.length()); under cards.substring(h,cards.length()) cards.substring cards h cards.length() cards.length cards cards = under + top cards under + top under top System.out.println(cards) System.out.println System.out System System.out cards cards = s.next() cards s.next() s.next s public static void main(String args[]){
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String args[] args public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String cards = s.next();
		while(!"-".equals(cards)){
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		}
	}
	public static void main(String args[]){
		new Main().run();
	}
} public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String cards = s.next();
		while(!"-".equals(cards)){
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		}
	}
	public static void main(String args[]){
		new Main().run();
	}
} Main
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String cards = s.next();
		while(!"-".equals(cards)){
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		}
	}
	public static void main(String args[]){
		new Main().run();
	}
}