import java.io.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m; //???????????£??????????????????
		StringBuffer cards;; 
		String shuCards = "";

		while(true){
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		}
    }
 
} import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m; //???????????£??????????????????
		StringBuffer cards;; 
		String shuCards = "";

		while(true){
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		}
    }
 
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m; //???????????£??????????????????
		StringBuffer cards;; 
		String shuCards = "";

		while(true){
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		}
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m; //???????????£??????????????????
		StringBuffer cards;; 
		String shuCards = "";

		while(true){
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		}
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int m; m StringBuffer cards; cards String shuCards = ""; shuCards "" while(true){
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		} true {
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		} cards = new StringBuffer(br.readLine()) cards new StringBuffer(br.readLine()) if(cards.toString().equals("-")){break;} cards.toString().equals("-") cards.toString().equals cards.toString() cards.toString cards "-" {break;} break; m = Integer.parseInt(br.readLine()) m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int cnt = 0; cnt 0 while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			} cnt++ != m cnt++ cnt m {
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			} int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br shuCards = cards.substring(h, cards.length()) shuCards cards.substring(h, cards.length()) cards.substring cards h cards.length() cards.length cards shuCards += cards.substring(0, h) shuCards cards.substring(0, h) cards.substring cards 0 h cards.delete(0, cards.length()) cards.delete cards 0 cards.length() cards.length cards cards.append(shuCards) cards.append cards shuCards System.out.println(shuCards) System.out.println System.out System System.out shuCards String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m; //???????????£??????????????????
		StringBuffer cards;; 
		String shuCards = "";

		while(true){
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		}
    }
 
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m; //???????????£??????????????????
		StringBuffer cards;; 
		String shuCards = "";

		while(true){
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		}
    }
 
} Main
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m; //???????????£??????????????????
		StringBuffer cards;; 
		String shuCards = "";

		while(true){
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		}
    }
 
}