import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		}
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		}
	}
} Main public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		}
	} main {
		Scanner sc=new Scanner(System.in);
		while(true){
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		}
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) while(true){
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		} true {
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		} String str=sc.next(); str sc.next() sc.next sc if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			} str.equals("-") str.equals str "-" {
				break;
			} break; {
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			} char[] ar = str.toCharArray(); ar str.toCharArray() str.toCharArray str Queue<Character> q = new LinkedList<Character>(); q new LinkedList<Character>() for(char ch:ar){
					q.offer(ch);
				} char ch ar {
					q.offer(ch);
				} {
					q.offer(ch);
				} q.offer(ch) q.offer q ch int m=sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				} int i=0; int i=0; i 0 i<m i m i++ i++ i {
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				} {
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				} int h=sc.nextInt(); h sc.nextInt() sc.nextInt sc for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					} int j=0; int j=0; j 0 j<h j h j++ j++ j {
						char ch=q.poll();
						q.offer(ch);
					} {
						char ch=q.poll();
						q.offer(ch);
					} char ch=q.poll(); ch q.poll() q.poll q q.offer(ch) q.offer q ch while(q.size()>0){
					System.out.print(q.poll());
				} q.size()>0 q.size() q.size q 0 {
					System.out.print(q.poll());
				} System.out.print(q.poll()) System.out.print System.out System System.out q.poll() q.poll q System.out.println() System.out.println System.out System System.out String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		}
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		}
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		}
	}
}