import java.util.Scanner;
class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while(true) {
            String str = scan.nextLine();
            if (str.equals("-")) {
                break;
            }
            int a = scan.nextInt();
            for (int i = 0;i < a; i++) {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            }
            System.out.println(str);
            str = scan.nextLine();
        }
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while(true) {
            String str = scan.nextLine();
            if (str.equals("-")) {
                break;
            }
            int a = scan.nextInt();
            for (int i = 0;i < a; i++) {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            }
            System.out.println(str);
            str = scan.nextLine();
        }
    }
} Main public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while(true) {
            String str = scan.nextLine();
            if (str.equals("-")) {
                break;
            }
            int a = scan.nextInt();
            for (int i = 0;i < a; i++) {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            }
            System.out.println(str);
            str = scan.nextLine();
        }
    } main {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while(true) {
            String str = scan.nextLine();
            if (str.equals("-")) {
                break;
            }
            int a = scan.nextInt();
            for (int i = 0;i < a; i++) {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            }
            System.out.println(str);
            str = scan.nextLine();
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true) {
            String str = scan.nextLine();
            if (str.equals("-")) {
                break;
            }
            int a = scan.nextInt();
            for (int i = 0;i < a; i++) {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            }
            System.out.println(str);
            str = scan.nextLine();
        } true {
            String str = scan.nextLine();
            if (str.equals("-")) {
                break;
            }
            int a = scan.nextInt();
            for (int i = 0;i < a; i++) {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            }
            System.out.println(str);
            str = scan.nextLine();
        } String str = scan.nextLine(); str scan.nextLine() scan.nextLine scan if (str.equals("-")) {
                break;
            } str.equals("-") str.equals str "-" {
                break;
            } break; int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan for (int i = 0;i < a; i++) {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            } {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            } int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan str = str.substring(h,str.length()) + str.substring(0, h) str str.substring(h,str.length()) + str.substring(0, h) str.substring(h,str.length()) str.substring str h str.length() str.length str str.substring(0, h) str.substring str 0 h System.out.println(str) System.out.println System.out System System.out str str = scan.nextLine() str scan.nextLine() scan.nextLine scan String args[] args
import java.util.Scanner;
class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while(true) {
            String str = scan.nextLine();
            if (str.equals("-")) {
                break;
            }
            int a = scan.nextInt();
            for (int i = 0;i < a; i++) {
                int h = scan.nextInt();
                str = str.substring(h,str.length()) + str.substring(0, h);
            }
            System.out.println(str);
            str = scan.nextLine();
        }
    }
}