import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner (System.in);
		final String END = "-";
		String word;
		String str;
		int m;
		int h;
		
		do {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} while(true);
		
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner (System.in);
		final String END = "-";
		String word;
		String str;
		int m;
		int h;
		
		do {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} while(true);
		
	}
} Main public static void main(String [] args) {
		Scanner scan = new Scanner (System.in);
		final String END = "-";
		String word;
		String str;
		int m;
		int h;
		
		do {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} while(true);
		
	} main {
		Scanner scan = new Scanner (System.in);
		final String END = "-";
		String word;
		String str;
		int m;
		int h;
		
		do {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} while(true);
		
	} Scanner scan = new Scanner (System.in); scan new Scanner (System.in) final String END = "-"; END "-" String word; word String str; str int m; m int h; h do {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} while(true); true {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} word = scan.next() word scan.next() scan.next scan if (word.equals(END)) break; word.equals(END) word.equals word END break; m = scan.nextInt() m scan.nextInt() scan.nextInt scan for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			} {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			} h = scan.nextInt() h scan.nextInt() scan.nextInt scan str = word + word str word + word word word int hh = h + word.length(); hh h + word.length() h word.length() word.length word word = str.substring(h, hh) word str.substring(h, hh) str.substring str h hh 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) {
		Scanner scan = new Scanner (System.in);
		final String END = "-";
		String word;
		String str;
		int m;
		int h;
		
		do {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} while(true);
		
	}
} public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner (System.in);
		final String END = "-";
		String word;
		String str;
		int m;
		int h;
		
		do {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} while(true);
		
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner (System.in);
		final String END = "-";
		String word;
		String str;
		int m;
		int h;
		
		do {
			word = scan.next();
			if (word.equals(END)) break;
			m = scan.nextInt();
			
			for (int i = 0; i < m; i++) {
				h = scan.nextInt();
				str = word + word;
				int hh = h + word.length();
				word = str.substring(h, hh);
			}
			
			System.out.println(word);
			
		} while(true);
		
	}
}

