import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String str, sub;
		int m, h;
		ArrayList<String> ans = new ArrayList<String>();
		
		while(true){
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			
			StringBuilder sb = new StringBuilder(str);
			
			m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			}
			
			ans.add(sb.toString());
		}
		
		for(String s : ans){
			System.out.println(s);
		}
	}
} import java.util.*; util.* java public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String str, sub;
		int m, h;
		ArrayList<String> ans = new ArrayList<String>();
		
		while(true){
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			
			StringBuilder sb = new StringBuilder(str);
			
			m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			}
			
			ans.add(sb.toString());
		}
		
		for(String s : ans){
			System.out.println(s);
		}
	}
} Main public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String str, sub;
		int m, h;
		ArrayList<String> ans = new ArrayList<String>();
		
		while(true){
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			
			StringBuilder sb = new StringBuilder(str);
			
			m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			}
			
			ans.add(sb.toString());
		}
		
		for(String s : ans){
			System.out.println(s);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String str, sub;
		int m, h;
		ArrayList<String> ans = new ArrayList<String>();
		
		while(true){
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			
			StringBuilder sb = new StringBuilder(str);
			
			m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			}
			
			ans.add(sb.toString());
		}
		
		for(String s : ans){
			System.out.println(s);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str str sub; sub int m m h; h ArrayList<String> ans = new ArrayList<String>(); ans new ArrayList<String>() while(true){
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			
			StringBuilder sb = new StringBuilder(str);
			
			m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			}
			
			ans.add(sb.toString());
		} true {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			
			StringBuilder sb = new StringBuilder(str);
			
			m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			}
			
			ans.add(sb.toString());
		} str = sc.next() str sc.next() sc.next sc if(str.equals("-")){
				break;
			} str.equals("-") str.equals str "-" {
				break;
			} break; StringBuilder sb = new StringBuilder(str); sb new StringBuilder(str) m = sc.nextInt() m sc.nextInt() sc.nextInt sc for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			} {
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			} h = sc.nextInt() h sc.nextInt() sc.nextInt sc sub = sb.substring(0, h) sub sb.substring(0, h) sb.substring sb 0 h sb.delete(0, h) sb.delete sb 0 h sb.append(sub) sb.append sb sub ans.add(sb.toString()) ans.add ans sb.toString() sb.toString sb for(String s : ans){
			System.out.println(s);
		} String s ans {
			System.out.println(s);
		} {
			System.out.println(s);
		} System.out.println(s) System.out.println System.out System System.out s String args[] args public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String str, sub;
		int m, h;
		ArrayList<String> ans = new ArrayList<String>();
		
		while(true){
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			
			StringBuilder sb = new StringBuilder(str);
			
			m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			}
			
			ans.add(sb.toString());
		}
		
		for(String s : ans){
			System.out.println(s);
		}
	}
} public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String str, sub;
		int m, h;
		ArrayList<String> ans = new ArrayList<String>();
		
		while(true){
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			
			StringBuilder sb = new StringBuilder(str);
			
			m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			}
			
			ans.add(sb.toString());
		}
		
		for(String s : ans){
			System.out.println(s);
		}
	}
} Main
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String str, sub;
		int m, h;
		ArrayList<String> ans = new ArrayList<String>();
		
		while(true){
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			
			StringBuilder sb = new StringBuilder(str);
			
			m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				h = sc.nextInt();
				
				sub = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(sub);
			}
			
			ans.add(sb.toString());
		}
		
		for(String s : ans){
			System.out.println(s);
		}
	}
}