import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String line = scan.next();//nextLine?????¨??????????????????????????§???
			if(line.equals("-")){
				scan.close();
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			}
			System.out.println(line);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String line = scan.next();//nextLine?????¨??????????????????????????§???
			if(line.equals("-")){
				scan.close();
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			}
			System.out.println(line);
		}
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String line = scan.next();//nextLine?????¨??????????????????????????§???
			if(line.equals("-")){
				scan.close();
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			}
			System.out.println(line);
		}
	} main {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String line = scan.next();//nextLine?????¨??????????????????????????§???
			if(line.equals("-")){
				scan.close();
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			}
			System.out.println(line);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(scan.hasNext()){
			String line = scan.next();//nextLine?????¨??????????????????????????§???
			if(line.equals("-")){
				scan.close();
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			}
			System.out.println(line);
		} scan.hasNext() scan.hasNext scan {
			String line = scan.next();//nextLine?????¨??????????????????????????§???
			if(line.equals("-")){
				scan.close();
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			}
			System.out.println(line);
		} String line = scan.next(); line scan.next() scan.next scan if(line.equals("-")){
				scan.close();
				break;
			} line.equals("-") line.equals line "-" {
				scan.close();
				break;
			} scan.close() scan.close scan break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			} {
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			} int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan String subline1 = line.substring(0, h); subline1 line.substring(0, h) line.substring line 0 h String subline2 = line.substring(h); subline2 line.substring(h) line.substring line h line = subline2.concat(subline1) line subline2.concat(subline1) subline2.concat subline2 subline1 System.out.println(line) System.out.println System.out System System.out line String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String line = scan.next();//nextLine?????¨??????????????????????????§???
			if(line.equals("-")){
				scan.close();
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			}
			System.out.println(line);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String line = scan.next();//nextLine?????¨??????????????????????????§???
			if(line.equals("-")){
				scan.close();
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			}
			System.out.println(line);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String line = scan.next();//nextLine?????¨??????????????????????????§???
			if(line.equals("-")){
				scan.close();
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String subline1 = line.substring(0, h);
				String subline2 = line.substring(h);
				line = subline2.concat(subline1);
			}
			System.out.println(line);
		}
	}
}