import java.util.Scanner;

public class Main {

	private static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {

		while(true){
			char[] cards = s.next().toCharArray();

			if(cards[0] == '-'){
				return;
			}

			char[] temp = new char[cards.length];
			int m = s.nextInt();

			for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			}

			System.out.println(cards);
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {

	private static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {

		while(true){
			char[] cards = s.next().toCharArray();

			if(cards[0] == '-'){
				return;
			}

			char[] temp = new char[cards.length];
			int m = s.nextInt();

			for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			}

			System.out.println(cards);
		}
	}

} Main private static Scanner s = new Scanner(System.in); s new Scanner(System.in) public static void main(String[] args) {

		while(true){
			char[] cards = s.next().toCharArray();

			if(cards[0] == '-'){
				return;
			}

			char[] temp = new char[cards.length];
			int m = s.nextInt();

			for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			}

			System.out.println(cards);
		}
	} main {

		while(true){
			char[] cards = s.next().toCharArray();

			if(cards[0] == '-'){
				return;
			}

			char[] temp = new char[cards.length];
			int m = s.nextInt();

			for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			}

			System.out.println(cards);
		}
	} while(true){
			char[] cards = s.next().toCharArray();

			if(cards[0] == '-'){
				return;
			}

			char[] temp = new char[cards.length];
			int m = s.nextInt();

			for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			}

			System.out.println(cards);
		} true {
			char[] cards = s.next().toCharArray();

			if(cards[0] == '-'){
				return;
			}

			char[] temp = new char[cards.length];
			int m = s.nextInt();

			for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			}

			System.out.println(cards);
		} char[] cards = s.next().toCharArray(); cards s.next().toCharArray() s.next().toCharArray s.next() s.next s if(cards[0] == '-'){
				return;
			} cards[0] == '-' cards[0] cards 0 '-' {
				return;
			} return; char[] temp = new char[cards.length]; temp new char[cards.length] cards.length cards cards.length int m = s.nextInt(); m s.nextInt() s.nextInt s for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			} int i=1; int i=1; i 1 i<=m i m i++ i++ i {
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			} {
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			} int h = s.nextInt(); h s.nextInt() s.nextInt s for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				} int j=0; int j=0; j 0 j<cards.length j cards.length cards cards.length j++ j++ j {
					temp[j] = cards[(j+h)%cards.length];
				} {
					temp[j] = cards[(j+h)%cards.length];
				} temp[j] = cards[(j+h)%cards.length] temp[j] temp j cards[(j+h)%cards.length] cards (j+h)%cards.length (j+h) j h cards.length cards cards.length for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				} int j=0; int j=0; j 0 j<cards.length j cards.length cards cards.length j++ j++ j {
					cards[j] = temp[j];
				} {
					cards[j] = temp[j];
				} cards[j] = temp[j] cards[j] cards j temp[j] temp j System.out.println(cards) System.out.println System.out System System.out cards String[] args args public class Main {

	private static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {

		while(true){
			char[] cards = s.next().toCharArray();

			if(cards[0] == '-'){
				return;
			}

			char[] temp = new char[cards.length];
			int m = s.nextInt();

			for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			}

			System.out.println(cards);
		}
	}

} public class Main {

	private static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {

		while(true){
			char[] cards = s.next().toCharArray();

			if(cards[0] == '-'){
				return;
			}

			char[] temp = new char[cards.length];
			int m = s.nextInt();

			for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			}

			System.out.println(cards);
		}
	}

} Main
import java.util.Scanner;

public class Main {

	private static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {

		while(true){
			char[] cards = s.next().toCharArray();

			if(cards[0] == '-'){
				return;
			}

			char[] temp = new char[cards.length];
			int m = s.nextInt();

			for(int i=1; i<=m; i++){
				int h = s.nextInt();

				for(int j=0; j<cards.length; j++){
					temp[j] = cards[(j+h)%cards.length];
				}

				for(int j=0; j<cards.length; j++){
					cards[j] = temp[j];
				}

			}

			System.out.println(cards);
		}
	}

}