import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		}

		for(String s : list){
			System.out.println(s);
		}
	}
} import java.util.*; util.* java public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		}

		for(String s : list){
			System.out.println(s);
		}
	}
} Main private static final Scanner scan = new Scanner(System.in); scan new Scanner(System.in) public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		}

		for(String s : list){
			System.out.println(s);
		}
	} main {
		List<String> list = new ArrayList<String>();
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		}

		for(String s : list){
			System.out.println(s);
		}
	} List<String> list = new ArrayList<String>(); list new ArrayList<String>() for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		} ; {
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		} {
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		} String input = scan.next(); input scan.next() scan.next scan if(input.equals("-")){
				break;
			} input.equals("-") input.equals input "-" {
				break;
			} break; int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			} int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			} {
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			} int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan String s = input.substring(0, m); s input.substring(0, m) input.substring input 0 m String s2 = input.substring(m); s2 input.substring(m) input.substring input m StringBuffer sb = new StringBuffer(); sb new StringBuffer() sb.append(s2).append(s) sb.append(s2).append sb.append(s2) sb.append sb s2 s input = sb.toString() input sb.toString() sb.toString sb list.add(input) list.add list input for(String s : list){
			System.out.println(s);
		} String s list {
			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{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		}

		for(String s : list){
			System.out.println(s);
		}
	}
} public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		}

		for(String s : list){
			System.out.println(s);
		}
	}
} Main
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int h = scan.nextInt();
			for(int i = 0; i < h; i++){
				int m = scan.nextInt();
				String s = input.substring(0, m);
				String s2 = input.substring(m);
	 			StringBuffer sb = new StringBuffer();
				sb.append(s2).append(s);
				input = sb.toString();
			}
			list.add(input);
		}

		for(String s : list){
			System.out.println(s);
		}
	}
}