import java.util.Scanner;

public class Main {

    public String shffl(String inS, int num) {
        String buf1 = inS.substring(0, num);
        String buf2 = inS.substring(num, inS.length());
        inS = buf2.concat(buf1);
        return inS;
    }

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

        while(true) {
            String pattern = scan.next();
            if (pattern.equals("-")) break;
            int times = Integer.parseInt(scan.next());
            for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            }
            System.out.println(pattern);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public String shffl(String inS, int num) {
        String buf1 = inS.substring(0, num);
        String buf2 = inS.substring(num, inS.length());
        inS = buf2.concat(buf1);
        return inS;
    }

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

        while(true) {
            String pattern = scan.next();
            if (pattern.equals("-")) break;
            int times = Integer.parseInt(scan.next());
            for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            }
            System.out.println(pattern);
        }
    }
} Main public String shffl(String inS, int num) {
        String buf1 = inS.substring(0, num);
        String buf2 = inS.substring(num, inS.length());
        inS = buf2.concat(buf1);
        return inS;
    } shffl {
        String buf1 = inS.substring(0, num);
        String buf2 = inS.substring(num, inS.length());
        inS = buf2.concat(buf1);
        return inS;
    } String buf1 = inS.substring(0, num); buf1 inS.substring(0, num) inS.substring inS 0 num String buf2 = inS.substring(num, inS.length()); buf2 inS.substring(num, inS.length()) inS.substring inS num inS.length() inS.length inS inS = buf2.concat(buf1) inS buf2.concat(buf1) buf2.concat buf2 buf1 return inS; inS String inS inS int num num public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Main app = new Main();

        while(true) {
            String pattern = scan.next();
            if (pattern.equals("-")) break;
            int times = Integer.parseInt(scan.next());
            for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            }
            System.out.println(pattern);
        }
    } main {
        Scanner scan = new Scanner(System.in);
        Main app = new Main();

        while(true) {
            String pattern = scan.next();
            if (pattern.equals("-")) break;
            int times = Integer.parseInt(scan.next());
            for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            }
            System.out.println(pattern);
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) Main app = new Main(); app new Main() while(true) {
            String pattern = scan.next();
            if (pattern.equals("-")) break;
            int times = Integer.parseInt(scan.next());
            for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            }
            System.out.println(pattern);
        } true {
            String pattern = scan.next();
            if (pattern.equals("-")) break;
            int times = Integer.parseInt(scan.next());
            for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            }
            System.out.println(pattern);
        } String pattern = scan.next(); pattern scan.next() scan.next scan if (pattern.equals("-")) break; pattern.equals("-") pattern.equals pattern "-" break; int times = Integer.parseInt(scan.next()); times Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            } int i = 0; int i = 0; i 0 i < times i times i++ i++ i {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            } {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            } int num = Integer.parseInt(scan.next()); num Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan pattern = app.shffl(pattern, num) pattern app.shffl(pattern, num) app.shffl app pattern num System.out.println(pattern) System.out.println System.out System System.out pattern String[] args args public class Main {

    public String shffl(String inS, int num) {
        String buf1 = inS.substring(0, num);
        String buf2 = inS.substring(num, inS.length());
        inS = buf2.concat(buf1);
        return inS;
    }

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

        while(true) {
            String pattern = scan.next();
            if (pattern.equals("-")) break;
            int times = Integer.parseInt(scan.next());
            for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            }
            System.out.println(pattern);
        }
    }
} public class Main {

    public String shffl(String inS, int num) {
        String buf1 = inS.substring(0, num);
        String buf2 = inS.substring(num, inS.length());
        inS = buf2.concat(buf1);
        return inS;
    }

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

        while(true) {
            String pattern = scan.next();
            if (pattern.equals("-")) break;
            int times = Integer.parseInt(scan.next());
            for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            }
            System.out.println(pattern);
        }
    }
} Main
import java.util.Scanner;

public class Main {

    public String shffl(String inS, int num) {
        String buf1 = inS.substring(0, num);
        String buf2 = inS.substring(num, inS.length());
        inS = buf2.concat(buf1);
        return inS;
    }

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

        while(true) {
            String pattern = scan.next();
            if (pattern.equals("-")) break;
            int times = Integer.parseInt(scan.next());
            for (int i = 0; i < times; i++) {
                int num = Integer.parseInt(scan.next());
                pattern = app.shffl(pattern, num);
            }
            System.out.println(pattern);
        }
    }
}
