import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

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

			StringBuilder sb = new StringBuilder(cards);
			for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			}
			System.out.println(sb.toString());
		}

		sc.close();

	}

} 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.next();
			if(cards.equals("-")) break;
			int shuffleNum = sc.nextInt();

			StringBuilder sb = new StringBuilder(cards);
			for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			}
			System.out.println(sb.toString());
		}

		sc.close();

	}

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

		Scanner sc = new Scanner(System.in);

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

			StringBuilder sb = new StringBuilder(cards);
			for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			}
			System.out.println(sb.toString());
		}

		sc.close();

	} main {

		Scanner sc = new Scanner(System.in);

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

			StringBuilder sb = new StringBuilder(cards);
			for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			}
			System.out.println(sb.toString());
		}

		sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			String cards = sc.next();
			if(cards.equals("-")) break;
			int shuffleNum = sc.nextInt();

			StringBuilder sb = new StringBuilder(cards);
			for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			}
			System.out.println(sb.toString());
		} true {
			String cards = sc.next();
			if(cards.equals("-")) break;
			int shuffleNum = sc.nextInt();

			StringBuilder sb = new StringBuilder(cards);
			for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			}
			System.out.println(sb.toString());
		} String cards = sc.next(); cards sc.next() sc.next sc if(cards.equals("-")) break; cards.equals("-") cards.equals cards "-" break; int shuffleNum = sc.nextInt(); shuffleNum sc.nextInt() sc.nextInt sc StringBuilder sb = new StringBuilder(cards); sb new StringBuilder(cards) for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			} int i=0; int i=0; i 0 i<shuffleNum i shuffleNum i++ i++ i {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			} {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			} int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc String cutStr = sb.substring(0, h); cutStr sb.substring(0, h) sb.substring sb 0 h sb.delete(0, h) sb.delete sb 0 h sb.append(cutStr) sb.append sb cutStr System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

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

			StringBuilder sb = new StringBuilder(cards);
			for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			}
			System.out.println(sb.toString());
		}

		sc.close();

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

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

			StringBuilder sb = new StringBuilder(cards);
			for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			}
			System.out.println(sb.toString());
		}

		sc.close();

	}

} 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.next();
			if(cards.equals("-")) break;
			int shuffleNum = sc.nextInt();

			StringBuilder sb = new StringBuilder(cards);
			for(int i=0; i<shuffleNum; i++) {
				int h = sc.nextInt();
				String cutStr = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(cutStr);
			}
			System.out.println(sb.toString());
		}

		sc.close();

	}

}
