import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		while(0 < 1) {
			String str = sc.next();
			StringBuffer strbf = new StringBuffer(str);
			if(str.equals("-")) break;
			int shuffle = sc.nextInt();
			for(int i = 0;i < shuffle;i++) {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			}
			System.out.println(strbf);
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		while(0 < 1) {
			String str = sc.next();
			StringBuffer strbf = new StringBuffer(str);
			if(str.equals("-")) break;
			int shuffle = sc.nextInt();
			for(int i = 0;i < shuffle;i++) {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			}
			System.out.println(strbf);
		}
		sc.close();
	}
} Main public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		while(0 < 1) {
			String str = sc.next();
			StringBuffer strbf = new StringBuffer(str);
			if(str.equals("-")) break;
			int shuffle = sc.nextInt();
			for(int i = 0;i < shuffle;i++) {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			}
			System.out.println(strbf);
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		while(0 < 1) {
			String str = sc.next();
			StringBuffer strbf = new StringBuffer(str);
			if(str.equals("-")) break;
			int shuffle = sc.nextInt();
			for(int i = 0;i < shuffle;i++) {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			}
			System.out.println(strbf);
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(0 < 1) {
			String str = sc.next();
			StringBuffer strbf = new StringBuffer(str);
			if(str.equals("-")) break;
			int shuffle = sc.nextInt();
			for(int i = 0;i < shuffle;i++) {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			}
			System.out.println(strbf);
		} 0 < 1 0 1 {
			String str = sc.next();
			StringBuffer strbf = new StringBuffer(str);
			if(str.equals("-")) break;
			int shuffle = sc.nextInt();
			for(int i = 0;i < shuffle;i++) {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			}
			System.out.println(strbf);
		} String str = sc.next(); str sc.next() sc.next sc StringBuffer strbf = new StringBuffer(str); strbf new StringBuffer(str) if(str.equals("-")) break; str.equals("-") str.equals str "-" break; int shuffle = sc.nextInt(); shuffle sc.nextInt() sc.nextInt sc for(int i = 0;i < shuffle;i++) {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			} int i = 0; int i = 0; i 0 i < shuffle i shuffle i++ i++ i {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			} {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			} int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc strbf.append(strbf.substring(0,num)) strbf.append strbf strbf.substring(0,num) strbf.substring strbf 0 num strbf.delete(0, num) strbf.delete strbf 0 num System.out.println(strbf) System.out.println System.out System System.out strbf sc.close() sc.close sc String[] args args
import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		while(0 < 1) {
			String str = sc.next();
			StringBuffer strbf = new StringBuffer(str);
			if(str.equals("-")) break;
			int shuffle = sc.nextInt();
			for(int i = 0;i < shuffle;i++) {
				int num = sc.nextInt();
				strbf.append(strbf.substring(0,num));
				//System.out.println(strbf);
				strbf.delete(0, num);
				//System.out.println(strbf);
			}
			System.out.println(strbf);
		}
		sc.close();
	}
}
