import java.util.Scanner;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		while(!n.equals("-")){
		    int shuffle_count = Integer.parseInt(sc.nextLine());
		    Queue<Character> cards = new ArrayDeque<>();
		    
		    for(char card: n.toCharArray()){
		        cards.add(card);
		    }
		    
		    for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    }
		    
		    for (Character card: cards){
		        System.out.print(card);
		    } 
		    
		    System.out.println();
		    
		    n = sc.nextLine();
		}
	}
} import java.util.Scanner; Scanner java.util import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		while(!n.equals("-")){
		    int shuffle_count = Integer.parseInt(sc.nextLine());
		    Queue<Character> cards = new ArrayDeque<>();
		    
		    for(char card: n.toCharArray()){
		        cards.add(card);
		    }
		    
		    for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    }
		    
		    for (Character card: cards){
		        System.out.print(card);
		    } 
		    
		    System.out.println();
		    
		    n = sc.nextLine();
		}
	}
} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		while(!n.equals("-")){
		    int shuffle_count = Integer.parseInt(sc.nextLine());
		    Queue<Character> cards = new ArrayDeque<>();
		    
		    for(char card: n.toCharArray()){
		        cards.add(card);
		    }
		    
		    for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    }
		    
		    for (Character card: cards){
		        System.out.print(card);
		    } 
		    
		    System.out.println();
		    
		    n = sc.nextLine();
		}
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		while(!n.equals("-")){
		    int shuffle_count = Integer.parseInt(sc.nextLine());
		    Queue<Character> cards = new ArrayDeque<>();
		    
		    for(char card: n.toCharArray()){
		        cards.add(card);
		    }
		    
		    for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    }
		    
		    for (Character card: cards){
		        System.out.print(card);
		    } 
		    
		    System.out.println();
		    
		    n = sc.nextLine();
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.nextLine(); n sc.nextLine() sc.nextLine sc while(!n.equals("-")){
		    int shuffle_count = Integer.parseInt(sc.nextLine());
		    Queue<Character> cards = new ArrayDeque<>();
		    
		    for(char card: n.toCharArray()){
		        cards.add(card);
		    }
		    
		    for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    }
		    
		    for (Character card: cards){
		        System.out.print(card);
		    } 
		    
		    System.out.println();
		    
		    n = sc.nextLine();
		} !n.equals("-") n.equals("-") n.equals n "-" {
		    int shuffle_count = Integer.parseInt(sc.nextLine());
		    Queue<Character> cards = new ArrayDeque<>();
		    
		    for(char card: n.toCharArray()){
		        cards.add(card);
		    }
		    
		    for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    }
		    
		    for (Character card: cards){
		        System.out.print(card);
		    } 
		    
		    System.out.println();
		    
		    n = sc.nextLine();
		} int shuffle_count = Integer.parseInt(sc.nextLine()); shuffle_count Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc Queue<Character> cards = new ArrayDeque<>(); cards new ArrayDeque<>() for(char card: n.toCharArray()){
		        cards.add(card);
		    } char card n.toCharArray() n.toCharArray n {
		        cards.add(card);
		    } {
		        cards.add(card);
		    } cards.add(card) cards.add cards card for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    } int i = 0; int i = 0; i 0 i < shuffle_count i shuffle_count i++ i++ i {
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    } {
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    } int shuffle_cards = Integer.parseInt(sc.nextLine()); shuffle_cards Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        } int l = 0; int l = 0; l 0 l < shuffle_cards l shuffle_cards l++ l++ l {
		            cards.add(cards.poll());
		        } {
		            cards.add(cards.poll());
		        } cards.add(cards.poll()) cards.add cards cards.poll() cards.poll cards for (Character card: cards){
		        System.out.print(card);
		    } Character card cards {
		        System.out.print(card);
		    } {
		        System.out.print(card);
		    } System.out.print(card) System.out.print System.out System System.out card System.out.println() System.out.println System.out System System.out n = sc.nextLine() n sc.nextLine() sc.nextLine sc String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		while(!n.equals("-")){
		    int shuffle_count = Integer.parseInt(sc.nextLine());
		    Queue<Character> cards = new ArrayDeque<>();
		    
		    for(char card: n.toCharArray()){
		        cards.add(card);
		    }
		    
		    for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    }
		    
		    for (Character card: cards){
		        System.out.print(card);
		    } 
		    
		    System.out.println();
		    
		    n = sc.nextLine();
		}
	}
} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		while(!n.equals("-")){
		    int shuffle_count = Integer.parseInt(sc.nextLine());
		    Queue<Character> cards = new ArrayDeque<>();
		    
		    for(char card: n.toCharArray()){
		        cards.add(card);
		    }
		    
		    for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    }
		    
		    for (Character card: cards){
		        System.out.print(card);
		    } 
		    
		    System.out.println();
		    
		    n = sc.nextLine();
		}
	}
} Main
import java.util.Scanner;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		while(!n.equals("-")){
		    int shuffle_count = Integer.parseInt(sc.nextLine());
		    Queue<Character> cards = new ArrayDeque<>();
		    
		    for(char card: n.toCharArray()){
		        cards.add(card);
		    }
		    
		    for (int i = 0; i < shuffle_count; i++){
		        int shuffle_cards = Integer.parseInt(sc.nextLine());
		        
		        for (int l = 0; l < shuffle_cards; l++){
		            cards.add(cards.poll());
		        }
		    }
		    
		    for (Character card: cards){
		        System.out.print(card);
		    } 
		    
		    System.out.println();
		    
		    n = sc.nextLine();
		}
	}
}
