
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        String result_a = null;
        String result_b = null;

        while (true) {
            String s = scan.next();

            if (s.equals("-")) {
                break;
            }

            int m = scan.nextInt();

            for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            }

            System.out.println(s);
        }

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

        while (true) {
            String s = scan.next();

            if (s.equals("-")) {
                break;
            }

            int m = scan.nextInt();

            for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            }

            System.out.println(s);
        }

    }
} Main public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        String result_a = null;
        String result_b = null;

        while (true) {
            String s = scan.next();

            if (s.equals("-")) {
                break;
            }

            int m = scan.nextInt();

            for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            }

            System.out.println(s);
        }

    } main {
        Scanner scan = new Scanner(System.in);
        String result_a = null;
        String result_b = null;

        while (true) {
            String s = scan.next();

            if (s.equals("-")) {
                break;
            }

            int m = scan.nextInt();

            for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            }

            System.out.println(s);
        }

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String result_a = null; result_a null String result_b = null; result_b null while (true) {
            String s = scan.next();

            if (s.equals("-")) {
                break;
            }

            int m = scan.nextInt();

            for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            }

            System.out.println(s);
        } true {
            String s = scan.next();

            if (s.equals("-")) {
                break;
            }

            int m = scan.nextInt();

            for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            }

            System.out.println(s);
        } String s = scan.next(); s scan.next() scan.next scan if (s.equals("-")) {
                break;
            } s.equals("-") s.equals s "-" {
                break;
            } break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            } {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            } int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan result_a = s.substring(0,h) result_a s.substring(0,h) s.substring s 0 h result_b = s.substring(h) result_b s.substring(h) s.substring s h s = result_b + result_a s result_b + result_a result_b result_a System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {
    public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        String result_a = null;
        String result_b = null;

        while (true) {
            String s = scan.next();

            if (s.equals("-")) {
                break;
            }

            int m = scan.nextInt();

            for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            }

            System.out.println(s);
        }

    }
} public class Main {
    public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        String result_a = null;
        String result_b = null;

        while (true) {
            String s = scan.next();

            if (s.equals("-")) {
                break;
            }

            int m = scan.nextInt();

            for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            }

            System.out.println(s);
        }

    }
} Main

import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        String result_a = null;
        String result_b = null;

        while (true) {
            String s = scan.next();

            if (s.equals("-")) {
                break;
            }

            int m = scan.nextInt();

            for (int i = 0; i < m; i++) {
                int h = scan.nextInt();
                result_a = s.substring(0,h);
                result_b = s.substring(h);
                
                s = result_b + result_a;


            }

            System.out.println(s);
        }

    }
}
