import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		StringBuilder sb = new StringBuilder();
		ArrayList<String> dis = new ArrayList<String>();
		while(true){
			str = br.readLine();
			if(str.equals("-")) break;
			int h = Integer.parseInt(br.readLine());
			for(int i=0 ;i<h ;i++){
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			}
			dis.add(str);
		}
		for(String s : dis){
			System.out.println(s);
		}
	}
} import java.io.*; io.* java import java.util.*; util.* java class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		StringBuilder sb = new StringBuilder();
		ArrayList<String> dis = new ArrayList<String>();
		while(true){
			str = br.readLine();
			if(str.equals("-")) break;
			int h = Integer.parseInt(br.readLine());
			for(int i=0 ;i<h ;i++){
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			}
			dis.add(str);
		}
		for(String s : dis){
			System.out.println(s);
		}
	}
} Main public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		StringBuilder sb = new StringBuilder();
		ArrayList<String> dis = new ArrayList<String>();
		while(true){
			str = br.readLine();
			if(str.equals("-")) break;
			int h = Integer.parseInt(br.readLine());
			for(int i=0 ;i<h ;i++){
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			}
			dis.add(str);
		}
		for(String s : dis){
			System.out.println(s);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		StringBuilder sb = new StringBuilder();
		ArrayList<String> dis = new ArrayList<String>();
		while(true){
			str = br.readLine();
			if(str.equals("-")) break;
			int h = Integer.parseInt(br.readLine());
			for(int i=0 ;i<h ;i++){
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			}
			dis.add(str);
		}
		for(String s : dis){
			System.out.println(s);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str StringBuilder sb = new StringBuilder(); sb new StringBuilder() ArrayList<String> dis = new ArrayList<String>(); dis new ArrayList<String>() while(true){
			str = br.readLine();
			if(str.equals("-")) break;
			int h = Integer.parseInt(br.readLine());
			for(int i=0 ;i<h ;i++){
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			}
			dis.add(str);
		} true {
			str = br.readLine();
			if(str.equals("-")) break;
			int h = Integer.parseInt(br.readLine());
			for(int i=0 ;i<h ;i++){
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			}
			dis.add(str);
		} str = br.readLine() str br.readLine() br.readLine br if(str.equals("-")) break; str.equals("-") str.equals str "-" break; int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i=0 ;i<h ;i++){
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			} int i=0 ; int i=0 ; i 0 i<h i h i++ i++ i {
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			} {
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			} int c = Integer.parseInt(br.readLine()); c Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br sb.append(str) sb.append sb str str = sb.substring(0,c) str sb.substring(0,c) sb.substring sb 0 c sb.delete(0,c) sb.delete sb 0 c str = sb.append(str).toString() str sb.append(str).toString() sb.append(str).toString sb.append(str) sb.append sb str sb.setLength(0) sb.setLength sb 0 dis.add(str) dis.add dis str for(String s : dis){
			System.out.println(s);
		} String s dis {
			System.out.println(s);
		} {
			System.out.println(s);
		} System.out.println(s) System.out.println System.out System System.out s String[] args args
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		StringBuilder sb = new StringBuilder();
		ArrayList<String> dis = new ArrayList<String>();
		while(true){
			str = br.readLine();
			if(str.equals("-")) break;
			int h = Integer.parseInt(br.readLine());
			for(int i=0 ;i<h ;i++){
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			}
			dis.add(str);
		}
		for(String s : dis){
			System.out.println(s);
		}
	}
}