import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n = 0;
		int tr = 0;
		String str = null;
		String strTmp1 = null;
		String strTmp2 = null;
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ans = new ArrayList<String>();
		while (true) {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		}
		for(int i = 0; i < ans.size(); ++i){
		System.out.println(ans.get(i));
		}
		sc.close();
	}

} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		int n = 0;
		int tr = 0;
		String str = null;
		String strTmp1 = null;
		String strTmp2 = null;
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ans = new ArrayList<String>();
		while (true) {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		}
		for(int i = 0; i < ans.size(); ++i){
		System.out.println(ans.get(i));
		}
		sc.close();
	}

} Main public static void main(String[] args) {
		int n = 0;
		int tr = 0;
		String str = null;
		String strTmp1 = null;
		String strTmp2 = null;
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ans = new ArrayList<String>();
		while (true) {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		}
		for(int i = 0; i < ans.size(); ++i){
		System.out.println(ans.get(i));
		}
		sc.close();
	} main {
		int n = 0;
		int tr = 0;
		String str = null;
		String strTmp1 = null;
		String strTmp2 = null;
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ans = new ArrayList<String>();
		while (true) {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		}
		for(int i = 0; i < ans.size(); ++i){
		System.out.println(ans.get(i));
		}
		sc.close();
	} int n = 0; n 0 int tr = 0; tr 0 String str = null; str null String strTmp1 = null; strTmp1 null String strTmp2 = null; strTmp2 null Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<String> ans = new ArrayList<String>(); ans new ArrayList<String>() while (true) {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		} true {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		} str = sc.next() str sc.next() sc.next sc if(str.equals("-")){
				break;
			} str.equals("-") str.equals str "-" {
				break;
			} break; n = sc.nextInt() n sc.nextInt() sc.nextInt sc for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 } {
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 } tr = sc.nextInt() tr sc.nextInt() sc.nextInt sc strTmp1 = str.substring(0, tr) strTmp1 str.substring(0, tr) str.substring str 0 tr strTmp2 = str.substring(tr) strTmp2 str.substring(tr) str.substring str tr str = (strTmp2+strTmp1) str (strTmp2+strTmp1) strTmp2 strTmp1 ans.add(str) ans.add ans str for(int i = 0; i < ans.size(); ++i){
		System.out.println(ans.get(i));
		} int i = 0; int i = 0; i 0 i < ans.size() i ans.size() ans.size ans ++i ++i i {
		System.out.println(ans.get(i));
		} {
		System.out.println(ans.get(i));
		} System.out.println(ans.get(i)) System.out.println System.out System System.out ans.get(i) ans.get ans i sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		int n = 0;
		int tr = 0;
		String str = null;
		String strTmp1 = null;
		String strTmp2 = null;
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ans = new ArrayList<String>();
		while (true) {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		}
		for(int i = 0; i < ans.size(); ++i){
		System.out.println(ans.get(i));
		}
		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		int n = 0;
		int tr = 0;
		String str = null;
		String strTmp1 = null;
		String strTmp2 = null;
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ans = new ArrayList<String>();
		while (true) {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		}
		for(int i = 0; i < ans.size(); ++i){
		System.out.println(ans.get(i));
		}
		sc.close();
	}

} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n = 0;
		int tr = 0;
		String str = null;
		String strTmp1 = null;
		String strTmp2 = null;
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ans = new ArrayList<String>();
		while (true) {
			str = sc.next();
			if(str.equals("-")){
				break;
			}
			 n = sc.nextInt();//?????£??????????????°
			 for(int i = 0; i < n; ++i){
				 tr = sc.nextInt();
				strTmp1 = str.substring(0, tr);
				strTmp2 = str.substring(tr);
				str = (strTmp2+strTmp1);
			 }
				ans.add(str);
		}
		for(int i = 0; i < ans.size(); ++i){
		System.out.println(ans.get(i));
		}
		sc.close();
	}

}