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