import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.next();
			if("-".equals(input)){
				break;
			}
			
			final int m = sc.nextInt();

			for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			}
			
			System.out.println(input);
		}
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.next();
			if("-".equals(input)){
				break;
			}
			
			final int m = sc.nextInt();

			for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			}
			
			System.out.println(input);
		}
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.next();
			if("-".equals(input)){
				break;
			}
			
			final int m = sc.nextInt();

			for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			}
			
			System.out.println(input);
		}
	} main {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.next();
			if("-".equals(input)){
				break;
			}
			
			final int m = sc.nextInt();

			for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			}
			
			System.out.println(input);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			String input = sc.next();
			if("-".equals(input)){
				break;
			}
			
			final int m = sc.nextInt();

			for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			}
			
			System.out.println(input);
		} true {
			String input = sc.next();
			if("-".equals(input)){
				break;
			}
			
			final int m = sc.nextInt();

			for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			}
			
			System.out.println(input);
		} String input = sc.next(); input sc.next() sc.next sc if("-".equals(input)){
				break;
			} "-".equals(input) "-".equals "-" input {
				break;
			} break; final int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			} {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			} final int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc input = input.substring(h) + input.substring(0, h) input input.substring(h) + input.substring(0, h) input.substring(h) input.substring input h input.substring(0, h) input.substring input 0 h System.out.println(input) System.out.println System.out System System.out input String args[] args public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.next();
			if("-".equals(input)){
				break;
			}
			
			final int m = sc.nextInt();

			for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			}
			
			System.out.println(input);
		}
	}
} public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.next();
			if("-".equals(input)){
				break;
			}
			
			final int m = sc.nextInt();

			for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			}
			
			System.out.println(input);
		}
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.next();
			if("-".equals(input)){
				break;
			}
			
			final int m = sc.nextInt();

			for (int i = 0; i < m; i++) {
				final int h = sc.nextInt();
				
				input = input.substring(h) + input.substring(0, h);
			}
			
			System.out.println(input);
		}
	}
}