import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String line, str1;
		int m,h;
		for(;;) {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		}
		System.out.print(sb);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String line, str1;
		int m,h;
		for(;;) {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		}
		System.out.print(sb);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String line, str1;
		int m,h;
		for(;;) {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		}
		System.out.print(sb);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String line, str1;
		int m,h;
		for(;;) {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		}
		System.out.print(sb);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() String line line str1; str1 int m m h; h for(;;) {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		} ; {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		} {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		} line = br.readLine() line br.readLine() br.readLine br if(line.equals("-")) break; line.equals("-") line.equals line "-" break; m = Integer.parseInt(br.readLine()) m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			} {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			} h = Integer.parseInt(br.readLine()) h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br str1 = line.substring(0, h) str1 line.substring(0, h) line.substring line 0 h line = line.substring(h, line.length()) + str1 line line.substring(h, line.length()) + str1 line.substring(h, line.length()) line.substring line h line.length() line.length line str1 sb.append(line).append("\n") sb.append(line).append sb.append(line) sb.append sb line "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String line, str1;
		int m,h;
		for(;;) {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		}
		System.out.print(sb);
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String line, str1;
		int m,h;
		for(;;) {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		}
		System.out.print(sb);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String line, str1;
		int m,h;
		for(;;) {
			line = br.readLine();
			if(line.equals("-")) break;
			m = Integer.parseInt(br.readLine());
			for(int i = 0; i < m; i++) {
				h = Integer.parseInt(br.readLine());
				str1 = line.substring(0, h);
				line = line.substring(h, line.length()) + str1;
			}
			sb.append(line).append("\n");
		}
		System.out.print(sb);
	}
}