import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			String pile = in.nextLine();
			if(pile.equals("-")) return;
			int m = in.nextInt();
			for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			}
			in.nextLine();
			System.out.println(pile);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			String pile = in.nextLine();
			if(pile.equals("-")) return;
			int m = in.nextInt();
			for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			}
			in.nextLine();
			System.out.println(pile);
		}
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			String pile = in.nextLine();
			if(pile.equals("-")) return;
			int m = in.nextInt();
			for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			}
			in.nextLine();
			System.out.println(pile);
		}
	} main {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			String pile = in.nextLine();
			if(pile.equals("-")) return;
			int m = in.nextInt();
			for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			}
			in.nextLine();
			System.out.println(pile);
		}
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) while(in.hasNext()) {
			String pile = in.nextLine();
			if(pile.equals("-")) return;
			int m = in.nextInt();
			for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			}
			in.nextLine();
			System.out.println(pile);
		} in.hasNext() in.hasNext in {
			String pile = in.nextLine();
			if(pile.equals("-")) return;
			int m = in.nextInt();
			for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			}
			in.nextLine();
			System.out.println(pile);
		} String pile = in.nextLine(); pile in.nextLine() in.nextLine in if(pile.equals("-")) return; pile.equals("-") pile.equals pile "-" return; int m = in.nextInt(); m in.nextInt() in.nextInt in for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			} int i=0; int i=0; i 0 i<m i m i++ i++ i {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			} {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			} int p = in.nextInt(); p in.nextInt() in.nextInt in String l = pile.substring(0, p); l pile.substring(0, p) pile.substring pile 0 p String r = pile.substring(p); r pile.substring(p) pile.substring pile p pile = r + l pile r + l r l in.nextLine() in.nextLine in System.out.println(pile) System.out.println System.out System System.out pile String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			String pile = in.nextLine();
			if(pile.equals("-")) return;
			int m = in.nextInt();
			for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			}
			in.nextLine();
			System.out.println(pile);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			String pile = in.nextLine();
			if(pile.equals("-")) return;
			int m = in.nextInt();
			for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			}
			in.nextLine();
			System.out.println(pile);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			String pile = in.nextLine();
			if(pile.equals("-")) return;
			int m = in.nextInt();
			for(int i=0;i<m;i++) {
				int p = in.nextInt();
				String l = pile.substring(0, p);
				String r = pile.substring(p);
				pile = r + l;
			}
			in.nextLine();
			System.out.println(pile);
		}
	}
}