import java.util.ArrayDeque;
import java.util.Scanner;

public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		String b;
		while(!(b=s.next()).equals("-")){
			char buf[]=b.toCharArray();
			ArrayDeque<Character> deque=new ArrayDeque<>();
			for(char c:buf)
				deque.add(c);
			for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			}
			for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll();
			System.out.println(String.valueOf(buf));
		}
	}
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Scanner; Scanner java.util public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		String b;
		while(!(b=s.next()).equals("-")){
			char buf[]=b.toCharArray();
			ArrayDeque<Character> deque=new ArrayDeque<>();
			for(char c:buf)
				deque.add(c);
			for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			}
			for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll();
			System.out.println(String.valueOf(buf));
		}
	}
} Main static final Scanner s=new Scanner(System.in); s new Scanner(System.in) public static void main(String args[]){
		String b;
		while(!(b=s.next()).equals("-")){
			char buf[]=b.toCharArray();
			ArrayDeque<Character> deque=new ArrayDeque<>();
			for(char c:buf)
				deque.add(c);
			for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			}
			for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll();
			System.out.println(String.valueOf(buf));
		}
	} main {
		String b;
		while(!(b=s.next()).equals("-")){
			char buf[]=b.toCharArray();
			ArrayDeque<Character> deque=new ArrayDeque<>();
			for(char c:buf)
				deque.add(c);
			for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			}
			for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll();
			System.out.println(String.valueOf(buf));
		}
	} String b; b while(!(b=s.next()).equals("-")){
			char buf[]=b.toCharArray();
			ArrayDeque<Character> deque=new ArrayDeque<>();
			for(char c:buf)
				deque.add(c);
			for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			}
			for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll();
			System.out.println(String.valueOf(buf));
		} !(b=s.next()).equals("-") (b=s.next()).equals("-") (b=s.next()).equals (b=s.next()) b s.next() s.next s "-" {
			char buf[]=b.toCharArray();
			ArrayDeque<Character> deque=new ArrayDeque<>();
			for(char c:buf)
				deque.add(c);
			for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			}
			for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll();
			System.out.println(String.valueOf(buf));
		} char buf[]=b.toCharArray(); buf b.toCharArray() b.toCharArray b ArrayDeque<Character> deque=new ArrayDeque<>(); deque new ArrayDeque<>() for(char c:buf)
				deque.add(c); char c buf deque.add(c); deque.add(c) deque.add deque c for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			} int i=s.nextInt(); int i=s.nextInt(); i s.nextInt() s.nextInt s i>0 i 0 i-- i-- i {
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			} {
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			} for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				} int j=s.nextInt(); int j=s.nextInt(); j s.nextInt() s.nextInt s j>0 j 0 j-- j-- j {
					deque.add(deque.poll());
				} {
					deque.add(deque.poll());
				} deque.add(deque.poll()) deque.add deque deque.poll() deque.poll deque for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll(); int i=0; int i=0; i 0 i<buf.length i buf.length buf buf.length i++ i++ i buf[i]=deque.poll(); buf[i]=deque.poll() buf[i] buf i deque.poll() deque.poll deque System.out.println(String.valueOf(buf)) System.out.println System.out System System.out String.valueOf(buf) String.valueOf String buf String args[] args public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		String b;
		while(!(b=s.next()).equals("-")){
			char buf[]=b.toCharArray();
			ArrayDeque<Character> deque=new ArrayDeque<>();
			for(char c:buf)
				deque.add(c);
			for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			}
			for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll();
			System.out.println(String.valueOf(buf));
		}
	}
} public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		String b;
		while(!(b=s.next()).equals("-")){
			char buf[]=b.toCharArray();
			ArrayDeque<Character> deque=new ArrayDeque<>();
			for(char c:buf)
				deque.add(c);
			for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			}
			for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll();
			System.out.println(String.valueOf(buf));
		}
	}
} Main
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main{

	static final Scanner s=new Scanner(System.in);

	public static void main(String args[]){
		String b;
		while(!(b=s.next()).equals("-")){
			char buf[]=b.toCharArray();
			ArrayDeque<Character> deque=new ArrayDeque<>();
			for(char c:buf)
				deque.add(c);
			for(int i=s.nextInt(); i>0; i--){
				for(int j=s.nextInt(); j>0; j--){
					deque.add(deque.poll());
				}
			}
			for(int i=0; i<buf.length; i++)
				buf[i]=deque.poll();
			System.out.println(String.valueOf(buf));
		}
	}
}