import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int numN;
		char ch;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			}
		}catch (NumberFormatException e) {
			System.out.println(e);
		} finally {
			sc.close();
		}
	}

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

	public static void main(String[] args) {

		int numN;
		char ch;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			}
		}catch (NumberFormatException e) {
			System.out.println(e);
		} finally {
			sc.close();
		}
	}

} Main public static void main(String[] args) {

		int numN;
		char ch;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			}
		}catch (NumberFormatException e) {
			System.out.println(e);
		} finally {
			sc.close();
		}
	} main {

		int numN;
		char ch;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			}
		}catch (NumberFormatException e) {
			System.out.println(e);
		} finally {
			sc.close();
		}
	} int numN; numN char ch; ch Scanner sc = null; sc null try {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			}
		}catch (NumberFormatException e) {
			System.out.println(e);
		} finally {
			sc.close();
		} catch (NumberFormatException e) {
			System.out.println(e);
		} NumberFormatException e {
			System.out.println(e);
		} System.out.println(e) System.out.println System.out System System.out e {
			sc.close();
		} sc.close() sc.close sc {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			}
		} sc = new Scanner(System.in) sc new Scanner(System.in) while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			} sc.hasNext() sc.hasNext sc {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			} String line = sc.next(); line sc.next() sc.next sc if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				} !line.equals("-") line.equals("-") line.equals line "-" {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				} char[] card = line.toCharArray(); card line.toCharArray() line.toCharArray line int numH = sc.nextInt(); numH sc.nextInt() sc.nextInt sc for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					} int i = 0; int i = 0; i 0 i < numH i numH i++ i++ i {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					} {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					} numN = sc.nextInt() numN sc.nextInt() sc.nextInt sc for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						} int j = 0; int j = 0; j 0 j < numN j numN j++ j++ j {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						} {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						} ch = card[0] ch card[0] card 0 for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							} int k = 0; int k = 0; k 0 k < card.length - 1 k card.length - 1 card.length card card.length 1 k++ k++ k {

								card[k] = card[k + 1];
							} {

								card[k] = card[k + 1];
							} card[k] = card[k + 1] card[k] card k card[k + 1] card k + 1 k 1 card[card.length - 1] = ch card[card.length - 1] card card.length - 1 card.length card card.length 1 ch System.out.println(card) System.out.println System.out System System.out card String[] args args public class Main {

	public static void main(String[] args) {

		int numN;
		char ch;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			}
		}catch (NumberFormatException e) {
			System.out.println(e);
		} finally {
			sc.close();
		}
	}

} public class Main {

	public static void main(String[] args) {

		int numN;
		char ch;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			}
		}catch (NumberFormatException e) {
			System.out.println(e);
		} finally {
			sc.close();
		}
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int numN;
		char ch;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

				String line = sc.next();
				//?????????????¢????
				if (!line.equals("-")) {
					char[] card = line.toCharArray();

					int numH = sc.nextInt();


					//?????£????????????????????°
					for (int i = 0; i < numH; i++) {

						//?????£?????????????????°
						numN = sc.nextInt();
						for (int j = 0; j < numN; j++) {
							ch = card[0];
							for (int k = 0; k < card.length - 1; k++) {

								card[k] = card[k + 1];
							}
							card[card.length - 1] = ch;
						}
					}

					System.out.println(card);
				}
			}
		}catch (NumberFormatException e) {
			System.out.println(e);
		} finally {
			sc.close();
		}
	}

}