import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);		
		while (true) {
			String s = sc.next();
			if(s.equals("-")) break;
			int shuffles = sc.nextInt();
			for (int i=0; i<shuffles; i++){
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			}
		
		System.out.println(s);
		
		}
		
	}
} import java.util.*; util.* java import java.lang.*; lang.* java class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);		
		while (true) {
			String s = sc.next();
			if(s.equals("-")) break;
			int shuffles = sc.nextInt();
			for (int i=0; i<shuffles; i++){
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			}
		
		System.out.println(s);
		
		}
		
	}
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);		
		while (true) {
			String s = sc.next();
			if(s.equals("-")) break;
			int shuffles = sc.nextInt();
			for (int i=0; i<shuffles; i++){
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			}
		
		System.out.println(s);
		
		}
		
	} main {
		
		Scanner sc = new Scanner(System.in);		
		while (true) {
			String s = sc.next();
			if(s.equals("-")) break;
			int shuffles = sc.nextInt();
			for (int i=0; i<shuffles; i++){
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			}
		
		System.out.println(s);
		
		}
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			String s = sc.next();
			if(s.equals("-")) break;
			int shuffles = sc.nextInt();
			for (int i=0; i<shuffles; i++){
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			}
		
		System.out.println(s);
		
		} true {
			String s = sc.next();
			if(s.equals("-")) break;
			int shuffles = sc.nextInt();
			for (int i=0; i<shuffles; i++){
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			}
		
		System.out.println(s);
		
		} String s = sc.next(); s sc.next() sc.next sc if(s.equals("-")) break; s.equals("-") s.equals s "-" break; int shuffles = sc.nextInt(); shuffles sc.nextInt() sc.nextInt sc for (int i=0; i<shuffles; i++){
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			} int i=0; int i=0; i 0 i<shuffles i shuffles i++ i++ i {
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			} {
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			} int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc String tmp = s.substring(h, s.length()); tmp s.substring(h, s.length()) s.substring s h s.length() s.length s tmp+=s.substring(0, h) tmp s.substring(0, h) s.substring s 0 h s =tmp s tmp System.out.println(s) System.out.println System.out System System.out s String[] args args
import java.util.*;
import java.lang.*;

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