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