import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out=new StringBuilder();
		String str;
		int q=0;
		while((str=br.readLine()).equals("-")==false){
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		}
		 // 最後にマッチしたインデックス(最後の改行)を取得
        int index = out.lastIndexOf("\n");
         
        // インデクスを指定して削除して表示
        out.deleteCharAt(index);
        System.out.println(out);
	}
} 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 {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out=new StringBuilder();
		String str;
		int q=0;
		while((str=br.readLine()).equals("-")==false){
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		}
		 // 最後にマッチしたインデックス(最後の改行)を取得
        int index = out.lastIndexOf("\n");
         
        // インデクスを指定して削除して表示
        out.deleteCharAt(index);
        System.out.println(out);
	}
} Main public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out=new StringBuilder();
		String str;
		int q=0;
		while((str=br.readLine()).equals("-")==false){
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		}
		 // 最後にマッチしたインデックス(最後の改行)を取得
        int index = out.lastIndexOf("\n");
         
        // インデクスを指定して削除して表示
        out.deleteCharAt(index);
        System.out.println(out);
	} main {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out=new StringBuilder();
		String str;
		int q=0;
		while((str=br.readLine()).equals("-")==false){
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		}
		 // 最後にマッチしたインデックス(最後の改行)を取得
        int index = out.lastIndexOf("\n");
         
        // インデクスを指定して削除して表示
        out.deleteCharAt(index);
        System.out.println(out);
	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder out=new StringBuilder(); out new StringBuilder() String str; str int q=0; q 0 while((str=br.readLine()).equals("-")==false){
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		} (str=br.readLine()).equals("-")==false (str=br.readLine()).equals("-") (str=br.readLine()).equals (str=br.readLine()) str br.readLine() br.readLine br "-" false {
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		} StringBuilder sb=new StringBuilder(); sb new StringBuilder() sb.append(str) sb.append sb str q=str.length() q str.length() str.length str int n=Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int p; p for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			} int i=0; int i=0; i 0 i<n i n i++ i++ i {
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			} {
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			} p=Integer.parseInt(br.readLine()) p Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br sb.append(sb.substring(0,p)) sb.append sb sb.substring(0,p) sb.substring sb 0 p sb.delete(0,p) sb.delete sb 0 p out.append(sb+"\n") out.append out sb+"\n" sb "\n" int index = out.lastIndexOf("\n"); index out.lastIndexOf("\n") out.lastIndexOf out "\n" out.deleteCharAt(index) out.deleteCharAt out index System.out.println(out) System.out.println System.out System System.out out String[] args args public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out=new StringBuilder();
		String str;
		int q=0;
		while((str=br.readLine()).equals("-")==false){
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		}
		 // 最後にマッチしたインデックス(最後の改行)を取得
        int index = out.lastIndexOf("\n");
         
        // インデクスを指定して削除して表示
        out.deleteCharAt(index);
        System.out.println(out);
	}
} public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out=new StringBuilder();
		String str;
		int q=0;
		while((str=br.readLine()).equals("-")==false){
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		}
		 // 最後にマッチしたインデックス(最後の改行)を取得
        int index = out.lastIndexOf("\n");
         
        // インデクスを指定して削除して表示
        out.deleteCharAt(index);
        System.out.println(out);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out=new StringBuilder();
		String str;
		int q=0;
		while((str=br.readLine()).equals("-")==false){
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		}
		 // 最後にマッチしたインデックス(最後の改行)を取得
        int index = out.lastIndexOf("\n");
         
        // インデクスを指定して削除して表示
        out.deleteCharAt(index);
        System.out.println(out);
	}
}