import java.util.Scanner;

//20180510
//08

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true) {
			String string = scanner.next();
			if("-".equals(string)){
				break;
			}
			int count = scanner.nextInt();
			for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			}
			System.out.println(string);
		}
		scanner.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true) {
			String string = scanner.next();
			if("-".equals(string)){
				break;
			}
			int count = scanner.nextInt();
			for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			}
			System.out.println(string);
		}
		scanner.close();
    }
} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true) {
			String string = scanner.next();
			if("-".equals(string)){
				break;
			}
			int count = scanner.nextInt();
			for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			}
			System.out.println(string);
		}
		scanner.close();
    } main {
		Scanner scanner = new Scanner(System.in);

		while(true) {
			String string = scanner.next();
			if("-".equals(string)){
				break;
			}
			int count = scanner.nextInt();
			for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			}
			System.out.println(string);
		}
		scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while(true) {
			String string = scanner.next();
			if("-".equals(string)){
				break;
			}
			int count = scanner.nextInt();
			for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			}
			System.out.println(string);
		} true {
			String string = scanner.next();
			if("-".equals(string)){
				break;
			}
			int count = scanner.nextInt();
			for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			}
			System.out.println(string);
		} String string = scanner.next(); string scanner.next() scanner.next scanner if("-".equals(string)){
				break;
			} "-".equals(string) "-".equals "-" string {
				break;
			} break; int count = scanner.nextInt(); count scanner.nextInt() scanner.nextInt scanner for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			} int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			} {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			} int shuffle = scanner.nextInt(); shuffle scanner.nextInt() scanner.nextInt scanner String tmp = string.substring(0, shuffle); tmp string.substring(0, shuffle) string.substring string 0 shuffle String out = string.substring(shuffle); out string.substring(shuffle) string.substring string shuffle string = out + tmp string out + tmp out tmp System.out.println(string) System.out.println System.out System System.out string scanner.close() scanner.close scanner String[] args args public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true) {
			String string = scanner.next();
			if("-".equals(string)){
				break;
			}
			int count = scanner.nextInt();
			for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			}
			System.out.println(string);
		}
		scanner.close();
    }
} public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true) {
			String string = scanner.next();
			if("-".equals(string)){
				break;
			}
			int count = scanner.nextInt();
			for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			}
			System.out.println(string);
		}
		scanner.close();
    }
} Main
import java.util.Scanner;

//20180510
//08

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true) {
			String string = scanner.next();
			if("-".equals(string)){
				break;
			}
			int count = scanner.nextInt();
			for(int i = 0;i < count;i++) {
				int shuffle = scanner.nextInt();
				String tmp = string.substring(0, shuffle);
				String out = string.substring(shuffle);
				string = out + tmp;
			}
			System.out.println(string);
		}
		scanner.close();
    }
}
