import java.util.Scanner;

public class Main {
		public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			int h, m, cnt = 0;
			String array[] = new String[10];
			String temp;
			String str;
			
			for(int i = 0; i < 10; i++) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			}
			sc.close();
			
			for(int i = 0; i < cnt; i++) {
				System.out.println(array[i]);
			}
		}
} import java.util.Scanner; Scanner java.util public class Main {
		public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			int h, m, cnt = 0;
			String array[] = new String[10];
			String temp;
			String str;
			
			for(int i = 0; i < 10; i++) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			}
			sc.close();
			
			for(int i = 0; i < cnt; i++) {
				System.out.println(array[i]);
			}
		}
} Main public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			int h, m, cnt = 0;
			String array[] = new String[10];
			String temp;
			String str;
			
			for(int i = 0; i < 10; i++) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			}
			sc.close();
			
			for(int i = 0; i < cnt; i++) {
				System.out.println(array[i]);
			}
		} main {
			Scanner sc = new Scanner(System.in);
			int h, m, cnt = 0;
			String array[] = new String[10];
			String temp;
			String str;
			
			for(int i = 0; i < 10; i++) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			}
			sc.close();
			
			for(int i = 0; i < cnt; i++) {
				System.out.println(array[i]);
			}
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int h h m m cnt = 0; cnt 0 String array[] = new String[10]; array new String[10] 10 String temp; temp String str; str for(int i = 0; i < 10; i++) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			} int i = 0; int i = 0; i 0 i < 10 i 10 i++ i++ i {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			} {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			} str = sc.next() str sc.next() sc.next sc if(str.equals("-")) {
					break;
				} str.equals("-") str.equals str "-" {
					break;
				} break; array[i] = str array[i] array i str m = sc.nextInt() m sc.nextInt() sc.nextInt sc for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				} int j = 0; int j = 0; j 0 j < m j m j++ j++ j {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				} {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				} h = sc.nextInt() h sc.nextInt() sc.nextInt sc temp = array[i].substring(0, h) temp array[i].substring(0, h) array[i].substring array[i] array i 0 h array[i] = array[i].substring(h) array[i] array i array[i].substring(h) array[i].substring array[i] array i h array[i] = array[i].concat(temp) array[i] array i array[i].concat(temp) array[i].concat array[i] array i temp cnt++ cnt sc.close() sc.close sc for(int i = 0; i < cnt; i++) {
				System.out.println(array[i]);
			} int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
				System.out.println(array[i]);
			} {
				System.out.println(array[i]);
			} System.out.println(array[i]) System.out.println System.out System System.out array[i] array i String args[] args public class Main {
		public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			int h, m, cnt = 0;
			String array[] = new String[10];
			String temp;
			String str;
			
			for(int i = 0; i < 10; i++) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			}
			sc.close();
			
			for(int i = 0; i < cnt; i++) {
				System.out.println(array[i]);
			}
		}
} public class Main {
		public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			int h, m, cnt = 0;
			String array[] = new String[10];
			String temp;
			String str;
			
			for(int i = 0; i < 10; i++) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			}
			sc.close();
			
			for(int i = 0; i < cnt; i++) {
				System.out.println(array[i]);
			}
		}
} Main
import java.util.Scanner;

public class Main {
		public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			int h, m, cnt = 0;
			String array[] = new String[10];
			String temp;
			String str;
			
			for(int i = 0; i < 10; i++) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			}
			sc.close();
			
			for(int i = 0; i < cnt; i++) {
				System.out.println(array[i]);
			}
		}
}
