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

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<String> ret = new ArrayList<String>();
		while (!in.hasNext("-")) {
			String n = in.next();
			int cnt = Integer.parseInt(in.next());
			int i, h;
			for (i = 0; i < cnt; i++) {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			}
			ret.add(n);
		}

		for (String text : ret) {
			System.out.println(text);
		}
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<String> ret = new ArrayList<String>();
		while (!in.hasNext("-")) {
			String n = in.next();
			int cnt = Integer.parseInt(in.next());
			int i, h;
			for (i = 0; i < cnt; i++) {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			}
			ret.add(n);
		}

		for (String text : ret) {
			System.out.println(text);
		}
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<String> ret = new ArrayList<String>();
		while (!in.hasNext("-")) {
			String n = in.next();
			int cnt = Integer.parseInt(in.next());
			int i, h;
			for (i = 0; i < cnt; i++) {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			}
			ret.add(n);
		}

		for (String text : ret) {
			System.out.println(text);
		}
	} main {
		Scanner in = new Scanner(System.in);
		List<String> ret = new ArrayList<String>();
		while (!in.hasNext("-")) {
			String n = in.next();
			int cnt = Integer.parseInt(in.next());
			int i, h;
			for (i = 0; i < cnt; i++) {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			}
			ret.add(n);
		}

		for (String text : ret) {
			System.out.println(text);
		}
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) List<String> ret = new ArrayList<String>(); ret new ArrayList<String>() while (!in.hasNext("-")) {
			String n = in.next();
			int cnt = Integer.parseInt(in.next());
			int i, h;
			for (i = 0; i < cnt; i++) {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			}
			ret.add(n);
		} !in.hasNext("-") in.hasNext("-") in.hasNext in "-" {
			String n = in.next();
			int cnt = Integer.parseInt(in.next());
			int i, h;
			for (i = 0; i < cnt; i++) {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			}
			ret.add(n);
		} String n = in.next(); n in.next() in.next in int cnt = Integer.parseInt(in.next()); cnt Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int i i h; h for (i = 0; i < cnt; i++) {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			} i = 0; i = 0 i 0 i < cnt i cnt i++ i++ i {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			} {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			} h = Integer.parseInt(in.next()) h Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in n = n.substring(h, n.length()) + n.substring(0, h) n n.substring(h, n.length()) + n.substring(0, h) n.substring(h, n.length()) n.substring n h n.length() n.length n n.substring(0, h) n.substring n 0 h ret.add(n) ret.add ret n for (String text : ret) {
			System.out.println(text);
		} String text ret {
			System.out.println(text);
		} {
			System.out.println(text);
		} System.out.println(text) System.out.println System.out System System.out text String[] args args
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<String> ret = new ArrayList<String>();
		while (!in.hasNext("-")) {
			String n = in.next();
			int cnt = Integer.parseInt(in.next());
			int i, h;
			for (i = 0; i < cnt; i++) {
				h = Integer.parseInt(in.next());
				n = n.substring(h, n.length()) + n.substring(0, h);
			}
			ret.add(n);
		}

		for (String text : ret) {
			System.out.println(text);
		}
	}
}