import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String s = sc.nextLine();
			if(s.equals("-"))	break;
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			}
			System.out.printf("%s\n", s);
		}
	}
}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String s = sc.nextLine();
			if(s.equals("-"))	break;
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			}
			System.out.printf("%s\n", s);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String s = sc.nextLine();
			if(s.equals("-"))	break;
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			}
			System.out.printf("%s\n", s);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String s = sc.nextLine();
			if(s.equals("-"))	break;
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			}
			System.out.printf("%s\n", s);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(sc.hasNextLine()) {
			String s = sc.nextLine();
			if(s.equals("-"))	break;
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			}
			System.out.printf("%s\n", s);
		} sc.hasNextLine() sc.hasNextLine sc {
			String s = sc.nextLine();
			if(s.equals("-"))	break;
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			}
			System.out.printf("%s\n", s);
		} String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc if(s.equals("-"))	break; s.equals("-") s.equals s "-" break; int m = Integer.parseInt(sc.nextLine()); m Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			} int i=0; int i=0; i 0 i < m i m i++ i++ i {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			} {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			} int h = Integer.parseInt(sc.nextLine()); h Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc String head = s.substring(0, h); head s.substring(0, h) s.substring s 0 h String tail = s.substring(h); tail s.substring(h) s.substring s h s = tail + head s tail + head tail head System.out.printf("%s\n", s) System.out.printf System.out System System.out "%s\n" s String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String s = sc.nextLine();
			if(s.equals("-"))	break;
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			}
			System.out.printf("%s\n", s);
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String s = sc.nextLine();
			if(s.equals("-"))	break;
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			}
			System.out.printf("%s\n", s);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String s = sc.nextLine();
			if(s.equals("-"))	break;
			int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				String head = s.substring(0, h);
				String tail = s.substring(h);
				s = tail + head;
			}
			System.out.printf("%s\n", s);
		}
	}
}

