public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        while (true) {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        }
    }
} public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        while (true) {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        }
    }
} Main public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        while (true) {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        }
    } main {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        while (true) {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        }
    } java.util.Scanner sc = new java.util.Scanner(System.in); sc new java.util.Scanner(System.in) while (true) {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        } true {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        } String first = sc.next(); first sc.next() sc.next sc if (first.equals("-")) { break; } first.equals("-") first.equals first "-" { break; } break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int h; h StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            } int i = 0; int i = 0; i 0 i < m i m i ++ i ++ i {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            } {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            } sb.delete(0, first.length()) sb.delete sb 0 first.length() first.length first h = sc.nextInt() h sc.nextInt() sc.nextInt sc sb.append(first.substring(h, first.length())) sb.append sb first.substring(h, first.length()) first.substring first h first.length() first.length first sb.append(first.substring(0, h)) sb.append sb first.substring(0, h) first.substring first 0 h first = sb.toString() first sb.toString() sb.toString sb System.out.println(first) System.out.println System.out System System.out first String[] args args public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        while (true) {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        }
    }
} public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        while (true) {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        }
    }
} Main
public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        while (true) {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        }
    }
}