import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		}

		System.out.print(sb);
	}

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

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		}

		System.out.print(sb);
	}

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

		while (true) {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		}

		System.out.print(sb);
	} main {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		}

		System.out.print(sb);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (true) {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		} true {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		} String cards = sc.nextLine(); cards sc.nextLine() sc.nextLine sc if ( cards.equals("-") ) break; cards.equals("-") cards.equals cards "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			} int i=0; int i=0; i 0 i < m i m i++ i++ i {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			} {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			} int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc String car = cards.substring(0, h); car cards.substring(0, h) cards.substring cards 0 h String ds = cards.substring(h); ds cards.substring(h) cards.substring cards h cards = ds + car cards ds + car ds car sc.nextLine() sc.nextLine sc sb.append(cards + "\n") sb.append sb cards + "\n" cards "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		}

		System.out.print(sb);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		}

		System.out.print(sb);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			String cards = sc.nextLine();
			if ( cards.equals("-") ) break;
			int m = sc.nextInt();

			for ( int i=0; i < m; i++) {
				int h = sc.nextInt();
				String car = cards.substring(0, h);
				String ds = cards.substring(h);
				cards = ds + car;
			}
			sc.nextLine(); // nextInt()??????????????£?????????\n????¶????????????????

			sb.append(cards + "\n");
		}

		System.out.print(sb);
	}

}