import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        int m;
        int h[];
        String ans[] = new String[11];
        int cnt = 0;

        while (true) {
            s = sc.next();
            if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            }
            m = sc.nextInt();
            h = new int[m];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }

            String tmp = s;
            String ttmp = s;

            for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            }
            ans[cnt] = tmp;
            cnt++;
        }
        // System.out.println("cnt: " + cnt);
        // for (int i = 0; i < cnt; i++) {
        // System.out.println(ans[i]);
        // }
        // sc.close();
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        int m;
        int h[];
        String ans[] = new String[11];
        int cnt = 0;

        while (true) {
            s = sc.next();
            if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            }
            m = sc.nextInt();
            h = new int[m];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }

            String tmp = s;
            String ttmp = s;

            for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            }
            ans[cnt] = tmp;
            cnt++;
        }
        // System.out.println("cnt: " + cnt);
        // for (int i = 0; i < cnt; i++) {
        // System.out.println(ans[i]);
        // }
        // sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        int m;
        int h[];
        String ans[] = new String[11];
        int cnt = 0;

        while (true) {
            s = sc.next();
            if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            }
            m = sc.nextInt();
            h = new int[m];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }

            String tmp = s;
            String ttmp = s;

            for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            }
            ans[cnt] = tmp;
            cnt++;
        }
        // System.out.println("cnt: " + cnt);
        // for (int i = 0; i < cnt; i++) {
        // System.out.println(ans[i]);
        // }
        // sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        String s;
        int m;
        int h[];
        String ans[] = new String[11];
        int cnt = 0;

        while (true) {
            s = sc.next();
            if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            }
            m = sc.nextInt();
            h = new int[m];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }

            String tmp = s;
            String ttmp = s;

            for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            }
            ans[cnt] = tmp;
            cnt++;
        }
        // System.out.println("cnt: " + cnt);
        // for (int i = 0; i < cnt; i++) {
        // System.out.println(ans[i]);
        // }
        // sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s; s int m; m int h[]; h String ans[] = new String[11]; ans new String[11] 11 int cnt = 0; cnt 0 while (true) {
            s = sc.next();
            if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            }
            m = sc.nextInt();
            h = new int[m];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }

            String tmp = s;
            String ttmp = s;

            for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            }
            ans[cnt] = tmp;
            cnt++;
        } true {
            s = sc.next();
            if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            }
            m = sc.nextInt();
            h = new int[m];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }

            String tmp = s;
            String ttmp = s;

            for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            }
            ans[cnt] = tmp;
            cnt++;
        } s = sc.next() s sc.next() sc.next sc if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            } s.equals("-") s.equals s "-" {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            } for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                } int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
                    System.out.println(ans[i]);
                } {
                    System.out.println(ans[i]);
                } System.out.println(ans[i]) System.out.println System.out System System.out ans[i] ans i sc.close() sc.close sc return; m = sc.nextInt() m sc.nextInt() sc.nextInt sc h = new int[m] h new int[m] m for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                h[i] = sc.nextInt();
            } {
                h[i] = sc.nextInt();
            } h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc String tmp = s; tmp s String ttmp = s; ttmp s for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            } {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            } ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i])) ttmp (tmp.substring(h[i]) + tmp.substring(0, h[i])) tmp.substring(h[i]) tmp.substring tmp h[i] h i tmp.substring(0, h[i]) tmp.substring tmp 0 h[i] h i tmp = ttmp tmp ttmp ans[cnt] = tmp ans[cnt] ans cnt tmp cnt++ cnt String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        int m;
        int h[];
        String ans[] = new String[11];
        int cnt = 0;

        while (true) {
            s = sc.next();
            if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            }
            m = sc.nextInt();
            h = new int[m];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }

            String tmp = s;
            String ttmp = s;

            for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            }
            ans[cnt] = tmp;
            cnt++;
        }
        // System.out.println("cnt: " + cnt);
        // for (int i = 0; i < cnt; i++) {
        // System.out.println(ans[i]);
        // }
        // sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        int m;
        int h[];
        String ans[] = new String[11];
        int cnt = 0;

        while (true) {
            s = sc.next();
            if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            }
            m = sc.nextInt();
            h = new int[m];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }

            String tmp = s;
            String ttmp = s;

            for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            }
            ans[cnt] = tmp;
            cnt++;
        }
        // System.out.println("cnt: " + cnt);
        // for (int i = 0; i < cnt; i++) {
        // System.out.println(ans[i]);
        // }
        // sc.close();
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        int m;
        int h[];
        String ans[] = new String[11];
        int cnt = 0;

        while (true) {
            s = sc.next();
            if (s.equals("-")) {
                for (int i = 0; i < cnt; i++) {
                    System.out.println(ans[i]);
                }
                sc.close();
                return;
            }
            m = sc.nextInt();
            h = new int[m];
            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
            }

            String tmp = s;
            String ttmp = s;

            for (int i = 0; i < m; i++) {
                ttmp = (tmp.substring(h[i]) + tmp.substring(0, h[i]));
                tmp = ttmp;
            }
            ans[cnt] = tmp;
            cnt++;
        }
        // System.out.println("cnt: " + cnt);
        // for (int i = 0; i < cnt; i++) {
        // System.out.println(ans[i]);
        // }
        // sc.close();
    }
}
