import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while (!s.equals("-")) {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while (!s.equals("-")) {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while (!s.equals("-")) {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    } main {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while (!s.equals("-")) {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String s = scanner.next(); s scanner.next() scanner.next scanner while (!s.equals("-")) {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        } !s.equals("-") s.equals("-") s.equals s "-" {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        } int m = scanner.nextInt(); m scanner.nextInt() scanner.nextInt scanner for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            } {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            } int h = scanner.nextInt(); h scanner.nextInt() scanner.nextInt scanner String s1 = s.substring(0, h); s1 s.substring(0, h) s.substring s 0 h String s2 = s.substring(h); s2 s.substring(h) s.substring s h s = s2 + s1 s s2 + s1 s2 s1 System.out.println(s) System.out.println System.out System System.out s s = scanner.next() s scanner.next() scanner.next scanner String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while (!s.equals("-")) {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while (!s.equals("-")) {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while (!s.equals("-")) {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
}
