import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		}
	}

	
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		}
	}

	
} Main public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		}
	} main {

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		} ; {
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		} {
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		} String input = scan.next(); input scan.next() scan.next scan if(input.equals("-")){
				break;
			} input.equals("-") input.equals input "-" {
				break;
			} break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan int len = input.length(); len input.length() input.length input String output = input; output input List<Character> listC = new ArrayList<Character>(); listC new ArrayList<Character>() for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			} int i = 0; int i = 0; i 0 i < len i len i++ i++ i {
				char c = output.charAt(i);
				listC.add(c);
			} {
				char c = output.charAt(i);
				listC.add(c);
			} char c = output.charAt(i); c output.charAt(i) output.charAt output i listC.add(c) listC.add listC c for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			} {
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			} int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				} int j = 0; int j = 0; j 0 j < h j h j++ j++ j {
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				} {
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				} char c = listC.get(0); c listC.get(0) listC.get listC 0 listC.remove(0) listC.remove listC 0 listC.add(c) listC.add listC c for(char c : listC){
				System.out.print(c);
			} char c listC {
				System.out.print(c);
			} {
				System.out.print(c);
			} System.out.print(c) System.out.print System.out System System.out c System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		}
	}

	
} public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		}
	}

	
} Main
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		}
	}

	
}