import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        while (true) {
            char[] cs = input.next().toCharArray();
            if (cs.length == 1 && cs[0] == '-') break;
            int m = input.nextInt();
            for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            }
            System.out.println(cs);
        }
    }
} import java.util.*; util.* java public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        while (true) {
            char[] cs = input.next().toCharArray();
            if (cs.length == 1 && cs[0] == '-') break;
            int m = input.nextInt();
            for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            }
            System.out.println(cs);
        }
    }
} Main public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    } main {
        Main main = new Main();
        main.solv();
    } Main main = new Main(); main new Main() main.solv() main.solv main String[] args args private void solv() {
        Scanner input = new Scanner(System.in);
        while (true) {
            char[] cs = input.next().toCharArray();
            if (cs.length == 1 && cs[0] == '-') break;
            int m = input.nextInt();
            for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            }
            System.out.println(cs);
        }
    } solv {
        Scanner input = new Scanner(System.in);
        while (true) {
            char[] cs = input.next().toCharArray();
            if (cs.length == 1 && cs[0] == '-') break;
            int m = input.nextInt();
            for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            }
            System.out.println(cs);
        }
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) while (true) {
            char[] cs = input.next().toCharArray();
            if (cs.length == 1 && cs[0] == '-') break;
            int m = input.nextInt();
            for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            }
            System.out.println(cs);
        } true {
            char[] cs = input.next().toCharArray();
            if (cs.length == 1 && cs[0] == '-') break;
            int m = input.nextInt();
            for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            }
            System.out.println(cs);
        } char[] cs = input.next().toCharArray(); cs input.next().toCharArray() input.next().toCharArray input.next() input.next input if (cs.length == 1 && cs[0] == '-') break; cs.length == 1 && cs[0] == '-' cs.length == 1 cs.length cs cs.length 1 cs[0] == '-' cs[0] cs 0 '-' break; int m = input.nextInt(); m input.nextInt() input.nextInt input for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            } {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            } int h = input.nextInt(); h input.nextInt() input.nextInt input char[] temp = new char[h]; temp new char[h] h for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                } int j = 0; int j = 0; j 0 j < h j h j++ j++ j {
                    temp[j] = cs[j];
                } {
                    temp[j] = cs[j];
                } temp[j] = cs[j] temp[j] temp j cs[j] cs j for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                } int j = h; int j = h; j h j < cs.length j cs.length cs cs.length j++ j++ j {
                    cs[j - h] = cs[j];
                } {
                    cs[j - h] = cs[j];
                } cs[j - h] = cs[j] cs[j - h] cs j - h j h cs[j] cs j for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                } int j = cs.length - h; int j = cs.length - h; j cs.length - h cs.length cs cs.length h j < cs.length j cs.length cs cs.length j++ j++ j {
                    cs[j] = temp[j - (cs.length - h)];
                } {
                    cs[j] = temp[j - (cs.length - h)];
                } cs[j] = temp[j - (cs.length - h)] cs[j] cs j temp[j - (cs.length - h)] temp j - (cs.length - h) j (cs.length - h) cs.length cs cs.length h System.out.println(cs) System.out.println System.out System System.out cs public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        while (true) {
            char[] cs = input.next().toCharArray();
            if (cs.length == 1 && cs[0] == '-') break;
            int m = input.nextInt();
            for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            }
            System.out.println(cs);
        }
    }
} public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        while (true) {
            char[] cs = input.next().toCharArray();
            if (cs.length == 1 && cs[0] == '-') break;
            int m = input.nextInt();
            for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            }
            System.out.println(cs);
        }
    }
} Main
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        while (true) {
            char[] cs = input.next().toCharArray();
            if (cs.length == 1 && cs[0] == '-') break;
            int m = input.nextInt();
            for (int i = 0; i < m; i++) {
                int h = input.nextInt();
                char[] temp = new char[h];
                for (int j = 0; j < h; j++) {
                    temp[j] = cs[j];
                }
                for (int j = h; j < cs.length; j++) {
                    cs[j - h] = cs[j];
                }
                for (int j = cs.length - h; j < cs.length; j++) {
                    cs[j] = temp[j - (cs.length - h)];
                }
            }
            System.out.println(cs);
        }
    }
}