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

		}
	}

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

		}
	}

} Main public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String str = scan.next();
			if("-".equals(str)){
				break;
			}
			int n = scan.nextInt();
			for(int i = 0; i < n;i++){
				int h = scan.nextInt();
				str = str.substring(h)+str.substring(0, h);
			}
			System.out.println(str);

		}
	} main {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String str = scan.next();
			if("-".equals(str)){
				break;
			}
			int n = scan.nextInt();
			for(int i = 0; i < n;i++){
				int h = scan.nextInt();
				str = str.substring(h)+str.substring(0, h);
			}
			System.out.println(str);

		}
	} java.util.Scanner scan = new java.util.Scanner(System.in); scan new java.util.Scanner(System.in) while(true){
			String str = scan.next();
			if("-".equals(str)){
				break;
			}
			int n = scan.nextInt();
			for(int i = 0; i < n;i++){
				int h = scan.nextInt();
				str = str.substring(h)+str.substring(0, h);
			}
			System.out.println(str);

		} true {
			String str = scan.next();
			if("-".equals(str)){
				break;
			}
			int n = scan.nextInt();
			for(int i = 0; i < n;i++){
				int h = scan.nextInt();
				str = str.substring(h)+str.substring(0, h);
			}
			System.out.println(str);

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

		}
	}

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

		}
	}

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

		}
	}

}