import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			String s = stdIn.next();
			if(s.equals("-"))
				break;
			int m = stdIn.nextInt();
			for (int i=0; i<m; i++) {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			}
			System.out.println(s);
		}
	}
} import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			String s = stdIn.next();
			if(s.equals("-"))
				break;
			int m = stdIn.nextInt();
			for (int i=0; i<m; i++) {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			}
			System.out.println(s);
		}
	}
} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			String s = stdIn.next();
			if(s.equals("-"))
				break;
			int m = stdIn.nextInt();
			for (int i=0; i<m; i++) {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			}
			System.out.println(s);
		}
	} main {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			String s = stdIn.next();
			if(s.equals("-"))
				break;
			int m = stdIn.nextInt();
			for (int i=0; i<m; i++) {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			}
			System.out.println(s);
		}
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) while(true){
			String s = stdIn.next();
			if(s.equals("-"))
				break;
			int m = stdIn.nextInt();
			for (int i=0; i<m; i++) {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			}
			System.out.println(s);
		} true {
			String s = stdIn.next();
			if(s.equals("-"))
				break;
			int m = stdIn.nextInt();
			for (int i=0; i<m; i++) {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			}
			System.out.println(s);
		} String s = stdIn.next(); s stdIn.next() stdIn.next stdIn if(s.equals("-"))
				break; s.equals("-") s.equals s "-" break; int m = stdIn.nextInt(); m stdIn.nextInt() stdIn.nextInt stdIn for (int i=0; i<m; i++) {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			} int i=0; int i=0; i 0 i<m i m i++ i++ i {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			} {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			} int h = stdIn.nextInt(); h stdIn.nextInt() stdIn.nextInt stdIn String temp = s.substring(h,s.length()); temp s.substring(h,s.length()) s.substring s h s.length() s.length s temp += s.substring(0,h) temp s.substring(0,h) s.substring s 0 h s = temp s temp System.out.println(s) System.out.println System.out System System.out s String[] args args
import java.util.*;

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