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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		ArrayList<String[]> all = new ArrayList<String[]>();

		String line = "";

		int pat = 0;

		while (true) {
			line = sc.nextLine();
			if (line.equals("-")) {
				break;
			}

			String shuffle = sc.nextLine();
			int shuffle_int = Integer.parseInt(shuffle);

			String[] kari = new String[2 + shuffle_int];
			kari[0] = line;
			kari[1] = shuffle;

			for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			}
			all.add(kari);
			pat++;
		}

		for (int i = 0; i < pat; i++) {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		}

	}

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

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		ArrayList<String[]> all = new ArrayList<String[]>();

		String line = "";

		int pat = 0;

		while (true) {
			line = sc.nextLine();
			if (line.equals("-")) {
				break;
			}

			String shuffle = sc.nextLine();
			int shuffle_int = Integer.parseInt(shuffle);

			String[] kari = new String[2 + shuffle_int];
			kari[0] = line;
			kari[1] = shuffle;

			for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			}
			all.add(kari);
			pat++;
		}

		for (int i = 0; i < pat; i++) {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		}

	}

} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		ArrayList<String[]> all = new ArrayList<String[]>();

		String line = "";

		int pat = 0;

		while (true) {
			line = sc.nextLine();
			if (line.equals("-")) {
				break;
			}

			String shuffle = sc.nextLine();
			int shuffle_int = Integer.parseInt(shuffle);

			String[] kari = new String[2 + shuffle_int];
			kari[0] = line;
			kari[1] = shuffle;

			for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			}
			all.add(kari);
			pat++;
		}

		for (int i = 0; i < pat; i++) {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		}

	} main {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		ArrayList<String[]> all = new ArrayList<String[]>();

		String line = "";

		int pat = 0;

		while (true) {
			line = sc.nextLine();
			if (line.equals("-")) {
				break;
			}

			String shuffle = sc.nextLine();
			int shuffle_int = Integer.parseInt(shuffle);

			String[] kari = new String[2 + shuffle_int];
			kari[0] = line;
			kari[1] = shuffle;

			for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			}
			all.add(kari);
			pat++;
		}

		for (int i = 0; i < pat; i++) {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<String[]> all = new ArrayList<String[]>(); all new ArrayList<String[]>() String line = ""; line "" int pat = 0; pat 0 while (true) {
			line = sc.nextLine();
			if (line.equals("-")) {
				break;
			}

			String shuffle = sc.nextLine();
			int shuffle_int = Integer.parseInt(shuffle);

			String[] kari = new String[2 + shuffle_int];
			kari[0] = line;
			kari[1] = shuffle;

			for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			}
			all.add(kari);
			pat++;
		} true {
			line = sc.nextLine();
			if (line.equals("-")) {
				break;
			}

			String shuffle = sc.nextLine();
			int shuffle_int = Integer.parseInt(shuffle);

			String[] kari = new String[2 + shuffle_int];
			kari[0] = line;
			kari[1] = shuffle;

			for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			}
			all.add(kari);
			pat++;
		} line = sc.nextLine() line sc.nextLine() sc.nextLine sc if (line.equals("-")) {
				break;
			} line.equals("-") line.equals line "-" {
				break;
			} break; String shuffle = sc.nextLine(); shuffle sc.nextLine() sc.nextLine sc int shuffle_int = Integer.parseInt(shuffle); shuffle_int Integer.parseInt(shuffle) Integer.parseInt Integer shuffle String[] kari = new String[2 + shuffle_int]; kari new String[2 + shuffle_int] 2 + shuffle_int 2 shuffle_int kari[0] = line kari[0] kari 0 line kari[1] = shuffle kari[1] kari 1 shuffle for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			} int j = 0; int j = 0; j 0 j < shuffle_int j shuffle_int j++ j++ j {
				kari[2 + j] = sc.nextLine();
			} {
				kari[2 + j] = sc.nextLine();
			} kari[2 + j] = sc.nextLine() kari[2 + j] kari 2 + j 2 j sc.nextLine() sc.nextLine sc all.add(kari) all.add all kari pat++ pat for (int i = 0; i < pat; i++) {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		} int i = 0; int i = 0; i 0 i < pat i pat i++ i++ i {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		} {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		} String[] s = all.get(i); s all.get(i) all.get all i String str = s[0]; str s[0] s 0 int repeat = Integer.parseInt(s[1]); repeat Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			} int j = 0; int j = 0; j 0 j < repeat j repeat j++ j++ j {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			} {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			} int sh = Integer.parseInt(s[j + 2]); sh Integer.parseInt(s[j + 2]) Integer.parseInt Integer s[j + 2] s j + 2 j 2 String a = str.substring(0, sh); a str.substring(0, sh) str.substring str 0 sh String b = str.substring(sh); b str.substring(sh) str.substring str sh str = b + a str b + a b a System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		ArrayList<String[]> all = new ArrayList<String[]>();

		String line = "";

		int pat = 0;

		while (true) {
			line = sc.nextLine();
			if (line.equals("-")) {
				break;
			}

			String shuffle = sc.nextLine();
			int shuffle_int = Integer.parseInt(shuffle);

			String[] kari = new String[2 + shuffle_int];
			kari[0] = line;
			kari[1] = shuffle;

			for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			}
			all.add(kari);
			pat++;
		}

		for (int i = 0; i < pat; i++) {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		}

	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		ArrayList<String[]> all = new ArrayList<String[]>();

		String line = "";

		int pat = 0;

		while (true) {
			line = sc.nextLine();
			if (line.equals("-")) {
				break;
			}

			String shuffle = sc.nextLine();
			int shuffle_int = Integer.parseInt(shuffle);

			String[] kari = new String[2 + shuffle_int];
			kari[0] = line;
			kari[1] = shuffle;

			for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			}
			all.add(kari);
			pat++;
		}

		for (int i = 0; i < pat; i++) {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		}

	}

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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		ArrayList<String[]> all = new ArrayList<String[]>();

		String line = "";

		int pat = 0;

		while (true) {
			line = sc.nextLine();
			if (line.equals("-")) {
				break;
			}

			String shuffle = sc.nextLine();
			int shuffle_int = Integer.parseInt(shuffle);

			String[] kari = new String[2 + shuffle_int];
			kari[0] = line;
			kari[1] = shuffle;

			for (int j = 0; j < shuffle_int; j++) {
				kari[2 + j] = sc.nextLine();
			}
			all.add(kari);
			pat++;
		}

		for (int i = 0; i < pat; i++) {
			String[] s = all.get(i);
			String str = s[0];
			int repeat = Integer.parseInt(s[1]);
			for (int j = 0; j < repeat; j++) {
				int sh = Integer.parseInt(s[j + 2]);
				String a = str.substring(0, sh);
				String b = str.substring(sh);
				str = b + a;
			}
			System.out.println(str);
		}

	}

}