
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		}
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		}
	}
} Main public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		}
	} main {
		Scanner scn = new Scanner(System.in);
		while (true) {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		}
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) while (true) {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		} true {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		} String inputData = scn.next(); inputData scn.next() scn.next scn if (inputData.equals("-")) {
				break;
			} inputData.equals("-") inputData.equals inputData "-" {
				break;
			} break; int count = scn.nextInt(); count scn.nextInt() scn.nextInt scn int shuffleCount; shuffleCount for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			} int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			} {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			} shuffleCount = scn.nextInt() shuffleCount scn.nextInt() scn.nextInt scn inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount) inputData inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount) inputData.substring(shuffleCount) inputData.substring inputData shuffleCount inputData.substring(0, shuffleCount) inputData.substring inputData 0 shuffleCount System.out.println(inputData) System.out.println System.out System System.out inputData String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		}
	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			String inputData = scn.next();
			if (inputData.equals("-")) {
				break;
			}
			//char[] inputDatas = inputData.toCharArray();
			int count = scn.nextInt();
			int shuffleCount;
			for (int i = 0; i < count; i++) {
				shuffleCount = scn.nextInt();
				inputData = inputData.substring(shuffleCount) + inputData.substring(0, shuffleCount);
			}
			System.out.println(inputData);
			//String ChangedData = new String(inputDatas);
			//System.out.println(ChangedData);
		}
	}
}

