import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main (String[] args){
		while(true){
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		}
	}
	private static String shuffle(String order){
		int m=sc.nextInt();
		String str=order;
		for(int i=0;i<m;i++){
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		}
		return str;
	}
} import java.util.Scanner; Scanner java.util public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main (String[] args){
		while(true){
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		}
	}
	private static String shuffle(String order){
		int m=sc.nextInt();
		String str=order;
		for(int i=0;i<m;i++){
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		}
		return str;
	}
} Main private static Scanner sc=new Scanner(System.in); sc new Scanner(System.in) public static void main (String[] args){
		while(true){
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		}
	} main {
		while(true){
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		}
	} while(true){
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		} true {
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		} String order=sc.next(); order sc.next() sc.next sc if(order.equals("-")) break; order.equals("-") order.equals order "-" break; System.out.println(shuffle(order)) System.out.println System.out System System.out shuffle(order) shuffle order String[] args args private static String shuffle(String order){
		int m=sc.nextInt();
		String str=order;
		for(int i=0;i<m;i++){
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		}
		return str;
	} shuffle {
		int m=sc.nextInt();
		String str=order;
		for(int i=0;i<m;i++){
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		}
		return str;
	} int m=sc.nextInt(); m sc.nextInt() sc.nextInt sc String str=order; str order for(int i=0;i<m;i++){
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		} int i=0; int i=0; i 0 i<m i m i++ i++ i {
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		} {
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		} int h=sc.nextInt(); h sc.nextInt() sc.nextInt sc str=str.substring(h)+str.substring(0,h) str str.substring(h)+str.substring(0,h) str.substring(h) str.substring str h str.substring(0,h) str.substring str 0 h return str; str String order order public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main (String[] args){
		while(true){
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		}
	}
	private static String shuffle(String order){
		int m=sc.nextInt();
		String str=order;
		for(int i=0;i<m;i++){
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		}
		return str;
	}
} public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main (String[] args){
		while(true){
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		}
	}
	private static String shuffle(String order){
		int m=sc.nextInt();
		String str=order;
		for(int i=0;i<m;i++){
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		}
		return str;
	}
} Main
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main (String[] args){
		while(true){
			String order=sc.next();
			if(order.equals("-")) break;
			System.out.println(shuffle(order));
		}
	}
	private static String shuffle(String order){
		int m=sc.nextInt();
		String str=order;
		for(int i=0;i<m;i++){
			int h=sc.nextInt();
			str=str.substring(h)+str.substring(0,h);
		}
		return str;
	}
}