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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str;
		while ((str = br.readLine()) != null) {
			if (str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			
			System.out.println(str);
		}
	}

} 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 {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str;
		while ((str = br.readLine()) != null) {
			if (str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			
			System.out.println(str);
		}
	}

} Main public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str;
		while ((str = br.readLine()) != null) {
			if (str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			
			System.out.println(str);
		}
	} main {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str;
		while ((str = br.readLine()) != null) {
			if (str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			
			System.out.println(str);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str while ((str = br.readLine()) != null) {
			if (str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			
			System.out.println(str);
		} (str = br.readLine()) != null (str = br.readLine()) str br.readLine() br.readLine br null {
			if (str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			
			System.out.println(str);
		} if (str.equals("-")) break; str.equals("-") str.equals str "-" break; 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());
				str = str.substring(h, str.length()) + str.substring(0, h);
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			} {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			} int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br str = str.substring(h, str.length()) + str.substring(0, h) str str.substring(h, str.length()) + str.substring(0, h) str.substring(h, str.length()) str.substring str h str.length() str.length str str.substring(0, h) str.substring str 0 h System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str;
		while ((str = br.readLine()) != null) {
			if (str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			
			System.out.println(str);
		}
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str;
		while ((str = br.readLine()) != null) {
			if (str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			
			System.out.println(str);
		}
	}

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str;
		while ((str = br.readLine()) != null) {
			if (str.equals("-")) break;
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			
			System.out.println(str);
		}
	}

}