import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=scan.next();
		int len = 0;
		int point =0;
		String a ="";
		String b ="";
		while(!str.equals("-")){
			int m = scan.nextInt();
			len =str.length();
			for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			}
			System.out.println(str);
			str=scan.next();
		}
	}

} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=scan.next();
		int len = 0;
		int point =0;
		String a ="";
		String b ="";
		while(!str.equals("-")){
			int m = scan.nextInt();
			len =str.length();
			for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			}
			System.out.println(str);
			str=scan.next();
		}
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=scan.next();
		int len = 0;
		int point =0;
		String a ="";
		String b ="";
		while(!str.equals("-")){
			int m = scan.nextInt();
			len =str.length();
			for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			}
			System.out.println(str);
			str=scan.next();
		}
	} main {
		Scanner scan = new Scanner(System.in);
		String str=scan.next();
		int len = 0;
		int point =0;
		String a ="";
		String b ="";
		while(!str.equals("-")){
			int m = scan.nextInt();
			len =str.length();
			for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			}
			System.out.println(str);
			str=scan.next();
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str=scan.next(); str scan.next() scan.next scan int len = 0; len 0 int point =0; point 0 String a =""; a "" String b =""; b "" while(!str.equals("-")){
			int m = scan.nextInt();
			len =str.length();
			for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			}
			System.out.println(str);
			str=scan.next();
		} !str.equals("-") str.equals("-") str.equals str "-" {
			int m = scan.nextInt();
			len =str.length();
			for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			}
			System.out.println(str);
			str=scan.next();
		} int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan len =str.length() len str.length() str.length str for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			} int i=0; int i=0; i 0 i<m i m i++ i++ i {
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			} {
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			} point = scan.nextInt() point scan.nextInt() scan.nextInt scan a=str.substring(0,point++) a str.substring(0,point++) str.substring str 0 point++ point b=str.substring(point-1) b str.substring(point-1) str.substring str point-1 point 1 str=b+a str b+a b a System.out.println(str) System.out.println System.out System System.out str str=scan.next() str scan.next() scan.next scan String[] args args public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=scan.next();
		int len = 0;
		int point =0;
		String a ="";
		String b ="";
		while(!str.equals("-")){
			int m = scan.nextInt();
			len =str.length();
			for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			}
			System.out.println(str);
			str=scan.next();
		}
	}

} public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=scan.next();
		int len = 0;
		int point =0;
		String a ="";
		String b ="";
		while(!str.equals("-")){
			int m = scan.nextInt();
			len =str.length();
			for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			}
			System.out.println(str);
			str=scan.next();
		}
	}

} Main
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=scan.next();
		int len = 0;
		int point =0;
		String a ="";
		String b ="";
		while(!str.equals("-")){
			int m = scan.nextInt();
			len =str.length();
			for(int i=0;i<m;i++){
				point = scan.nextInt();
				a=str.substring(0,point++);
				b=str.substring(point-1);
				str=b+a;
			}
			System.out.println(str);
			str=scan.next();
		}
	}

}