import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			String line = std.nextLine();

			if(line.equals("-")){break;}

			int n = Integer.parseInt(std.nextLine());
			for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			}
			System.out.println(line);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			String line = std.nextLine();

			if(line.equals("-")){break;}

			int n = Integer.parseInt(std.nextLine());
			for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			}
			System.out.println(line);
		}
	}
} Main public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			String line = std.nextLine();

			if(line.equals("-")){break;}

			int n = Integer.parseInt(std.nextLine());
			for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			}
			System.out.println(line);
		}
	} main {
		Scanner std = new Scanner(System.in);
		while(true){
			String line = std.nextLine();

			if(line.equals("-")){break;}

			int n = Integer.parseInt(std.nextLine());
			for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			}
			System.out.println(line);
		}
	} Scanner std = new Scanner(System.in); std new Scanner(System.in) while(true){
			String line = std.nextLine();

			if(line.equals("-")){break;}

			int n = Integer.parseInt(std.nextLine());
			for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			}
			System.out.println(line);
		} true {
			String line = std.nextLine();

			if(line.equals("-")){break;}

			int n = Integer.parseInt(std.nextLine());
			for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			}
			System.out.println(line);
		} String line = std.nextLine(); line std.nextLine() std.nextLine std if(line.equals("-")){break;} line.equals("-") line.equals line "-" {break;} break; int n = Integer.parseInt(std.nextLine()); n Integer.parseInt(std.nextLine()) Integer.parseInt Integer std.nextLine() std.nextLine std for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			} int i=0; int i=0; i 0 i<n i n i++ i++ i {
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			} {
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			} int index = Integer.parseInt(std.nextLine()); index Integer.parseInt(std.nextLine()) Integer.parseInt Integer std.nextLine() std.nextLine std String newline = line.substring(index, line.length()); newline line.substring(index, line.length()) line.substring line index line.length() line.length line newline += line.substring(0,index) newline line.substring(0,index) line.substring line 0 index line = newline line newline 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 std = new Scanner(System.in);
		while(true){
			String line = std.nextLine();

			if(line.equals("-")){break;}

			int n = Integer.parseInt(std.nextLine());
			for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			}
			System.out.println(line);
		}
	}
} public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			String line = std.nextLine();

			if(line.equals("-")){break;}

			int n = Integer.parseInt(std.nextLine());
			for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			}
			System.out.println(line);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		while(true){
			String line = std.nextLine();

			if(line.equals("-")){break;}

			int n = Integer.parseInt(std.nextLine());
			for(int i=0; i<n; i++){
				int index = Integer.parseInt(std.nextLine());
				String newline = line.substring(index, line.length());
				newline += line.substring(0,index);
				line = newline;
			}
			System.out.println(line);
		}
	}
}