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));
		String str;
		while(!(str = br.readLine()).equals("-")){
			StringBuilder sb = new StringBuilder(str);
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb.toString());
		}
	}

} 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));
		String str;
		while(!(str = br.readLine()).equals("-")){
			StringBuilder sb = new StringBuilder(str);
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb.toString());
		}
	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!(str = br.readLine()).equals("-")){
			StringBuilder sb = new StringBuilder(str);
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb.toString());
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!(str = br.readLine()).equals("-")){
			StringBuilder sb = new StringBuilder(str);
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb.toString());
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str while(!(str = br.readLine()).equals("-")){
			StringBuilder sb = new StringBuilder(str);
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb.toString());
		} !(str = br.readLine()).equals("-") (str = br.readLine()).equals("-") (str = br.readLine()).equals (str = br.readLine()) str br.readLine() br.readLine br "-" {
			StringBuilder sb = new StringBuilder(str);
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb.toString());
		} StringBuilder sb = new StringBuilder(str); sb new StringBuilder(str) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			} {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			} int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br sb.append(sb.toString().substring(0, h)) sb.append sb sb.toString().substring(0, h) sb.toString().substring sb.toString() sb.toString sb 0 h sb.delete(0, h) sb.delete sb 0 h System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!(str = br.readLine()).equals("-")){
			StringBuilder sb = new StringBuilder(str);
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb.toString());
		}
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(!(str = br.readLine()).equals("-")){
			StringBuilder sb = new StringBuilder(str);
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb.toString());
		}
	}

} 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));
		String str;
		while(!(str = br.readLine()).equals("-")){
			StringBuilder sb = new StringBuilder(str);
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				sb.append(sb.toString().substring(0, h));
				sb.delete(0, h);
			}
			System.out.println(sb.toString());
		}
	}

}