import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder output = new StringBuilder();
        String word;
        int m;
        int h;
        int original_length;
        while (true) {
            word = scan.next();
            if ("-".equals(word))
                break;
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            }
            output.append(word + '\n');
        }
        System.out.print(output);
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder output = new StringBuilder();
        String word;
        int m;
        int h;
        int original_length;
        while (true) {
            word = scan.next();
            if ("-".equals(word))
                break;
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            }
            output.append(word + '\n');
        }
        System.out.print(output);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder output = new StringBuilder();
        String word;
        int m;
        int h;
        int original_length;
        while (true) {
            word = scan.next();
            if ("-".equals(word))
                break;
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            }
            output.append(word + '\n');
        }
        System.out.print(output);
    } main {
        Scanner scan = new Scanner(System.in);
        StringBuilder output = new StringBuilder();
        String word;
        int m;
        int h;
        int original_length;
        while (true) {
            word = scan.next();
            if ("-".equals(word))
                break;
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            }
            output.append(word + '\n');
        }
        System.out.print(output);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) StringBuilder output = new StringBuilder(); output new StringBuilder() String word; word int m; m int h; h int original_length; original_length while (true) {
            word = scan.next();
            if ("-".equals(word))
                break;
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            }
            output.append(word + '\n');
        } true {
            word = scan.next();
            if ("-".equals(word))
                break;
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            }
            output.append(word + '\n');
        } word = scan.next() word scan.next() scan.next scan if ("-".equals(word))
                break; "-".equals(word) "-".equals "-" word break; m = scan.nextInt() m scan.nextInt() scan.nextInt scan for (int i = 0; i < m; i++) {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            } {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            } h = scan.nextInt() h scan.nextInt() scan.nextInt scan original_length = word.length() original_length word.length() word.length word word = word + word.substring(0,h) word word + word.substring(0,h) word word.substring(0,h) word.substring word 0 h word = word.substring(word.length() - original_length) word word.substring(word.length() - original_length) word.substring word word.length() - original_length word.length() word.length word original_length output.append(word + '\n') output.append output word + '\n' word '\n' System.out.print(output) System.out.print System.out System System.out output String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder output = new StringBuilder();
        String word;
        int m;
        int h;
        int original_length;
        while (true) {
            word = scan.next();
            if ("-".equals(word))
                break;
            m = scan.nextInt();
            for (int i = 0; i < m; i++) {
                h = scan.nextInt();
                original_length = word.length();
                word = word + word.substring(0,h);
                word = word.substring(word.length() - original_length);
            }
            output.append(word + '\n');
        }
        System.out.print(output);
    }
}