import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		}
	} main {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		} true {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		} String cards = sc.nextLine(); cards sc.nextLine() sc.nextLine sc if (cards.equals("-")) {
				break;
			} cards.equals("-") cards.equals cards "-" {
				break;
			} break; String[] cds = cards.split(""); cds cards.split("") cards.split cards "" int cdlength = cards.length(); cdlength cards.length() cards.length cards String[] cds2 = new String[cdlength]; cds2 new String[cdlength] cdlength int repeat = Integer.parseInt(sc.nextLine()); repeat Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			} int i = 0; int i = 0; i 0 i < repeat i repeat i++ i++ i {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			} {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			} int shuffle = Integer.parseInt(sc.nextLine()); shuffle Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				} i % 2 == 0 i % 2 i 2 0 {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					} int j = 0, k = shuffle; int j = 0 j 0 k = shuffle; k shuffle j < cdlength j cdlength j++, k++ j++ j k++ k {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					} {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					} if (k == cdlength) {
							k  =0;
						} k == cdlength k cdlength {
							k  =0;
						} k  =0 k 0 cds2[j] = cds[k] cds2[j] cds2 j cds[k] cds k {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				} for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					} int j = 0, k = shuffle; int j = 0 j 0 k = shuffle; k shuffle j < cdlength j cdlength j++, k++ j++ j k++ k {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					} {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					} if (k == cdlength) {
							k = 0;
						} k == cdlength k cdlength {
							k = 0;
						} k = 0 k 0 cds[j] = cds2[k] cds[j] cds j cds2[k] cds2 k StringBuilder after = new StringBuilder(); after new StringBuilder() if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			} repeat % 2 == 0 repeat % 2 repeat 2 0 {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				} int i = 0; int i = 0; i 0 i < cdlength i cdlength i++ i++ i {
					after.append(cds[i]);
				} {
					after.append(cds[i]);
				} after.append(cds[i]) after.append after cds[i] cds i {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			} for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				} int i = 0; int i = 0; i 0 i < cdlength i cdlength i++ i++ i {
					after.append(cds2[i]);
				} {
					after.append(cds2[i]);
				} after.append(cds2[i]) after.append after cds2[i] cds2 i System.out.println(after.toString()) System.out.println System.out System System.out after.toString() after.toString after String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		}
	}
} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String cards = sc.nextLine();
			if (cards.equals("-")) {
				break;
			}
			String[] cds = cards.split("");
			int cdlength = cards.length();
			String[] cds2 = new String[cdlength];
			int repeat = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < repeat; i++) {
				int shuffle = Integer.parseInt(sc.nextLine());
				if (i % 2 == 0) {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k  =0;
						}
						cds2[j] = cds[k];
					}
				} else {
					for (int j = 0, k = shuffle; j < cdlength; j++, k++) {
						if (k == cdlength) {
							k = 0;
						}
						cds[j] = cds2[k];
					}
				}
			}
			StringBuilder after = new StringBuilder();
			if (repeat % 2 == 0) {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds[i]);
				}
			} else {
				for (int i = 0; i < cdlength; i++) {
					after.append(cds2[i]);
				}
			}
			System.out.println(after.toString());
		}
	}
}