import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        try {
            int m, i, j, k, wl;
            Scanner sc = new Scanner(System.in);
            String s;
            String[] r = new String[10];
            char[] t = new char[200];
            int[] h = new int[100];

            for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            }
            sc.close();

            int I = i;

            for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            }
        }
        catch (NumberFormatException e) {
            System.out.println(e);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main (String[] args) {
        try {
            int m, i, j, k, wl;
            Scanner sc = new Scanner(System.in);
            String s;
            String[] r = new String[10];
            char[] t = new char[200];
            int[] h = new int[100];

            for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            }
            sc.close();

            int I = i;

            for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            }
        }
        catch (NumberFormatException e) {
            System.out.println(e);
        }
    }
} Main public static void main (String[] args) {
        try {
            int m, i, j, k, wl;
            Scanner sc = new Scanner(System.in);
            String s;
            String[] r = new String[10];
            char[] t = new char[200];
            int[] h = new int[100];

            for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            }
            sc.close();

            int I = i;

            for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            }
        }
        catch (NumberFormatException e) {
            System.out.println(e);
        }
    } main {
        try {
            int m, i, j, k, wl;
            Scanner sc = new Scanner(System.in);
            String s;
            String[] r = new String[10];
            char[] t = new char[200];
            int[] h = new int[100];

            for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            }
            sc.close();

            int I = i;

            for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            }
        }
        catch (NumberFormatException e) {
            System.out.println(e);
        }
    } try {
            int m, i, j, k, wl;
            Scanner sc = new Scanner(System.in);
            String s;
            String[] r = new String[10];
            char[] t = new char[200];
            int[] h = new int[100];

            for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            }
            sc.close();

            int I = i;

            for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            }
        }
        catch (NumberFormatException e) {
            System.out.println(e);
        } catch (NumberFormatException e) {
            System.out.println(e);
        } NumberFormatException e {
            System.out.println(e);
        } System.out.println(e) System.out.println System.out System System.out e {
            int m, i, j, k, wl;
            Scanner sc = new Scanner(System.in);
            String s;
            String[] r = new String[10];
            char[] t = new char[200];
            int[] h = new int[100];

            for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            }
            sc.close();

            int I = i;

            for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            }
        } int m m i i j j k k wl; wl Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s; s String[] r = new String[10]; r new String[10] 10 char[] t = new char[200]; t new char[200] 200 int[] h = new int[100]; h new int[100] 100 for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            } i = 0; i = 0 i 0 true i++ i++ i {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            } {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            } s = sc.nextLine() s sc.nextLine() sc.nextLine sc if (s.equals("-")) break; s.equals("-") s.equals s "-" break; wl = s.length() wl s.length() s.length s char[] w = new char[wl]; w new char[wl] wl for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                } j = 0; j = 0 j 0 j < wl j wl j++ j++ j {
                    w[j] = s.charAt(j);
                } {
                    w[j] = s.charAt(j);
                } w[j] = s.charAt(j) w[j] w j s.charAt(j) s.charAt s j s = sc.nextLine() s sc.nextLine() sc.nextLine sc m = Integer.parseInt(s) m Integer.parseInt(s) Integer.parseInt Integer s for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                } j = 0; j = 0 j 0 j < m j m j++ j++ j {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                } {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                } s = sc.nextLine() s sc.nextLine() sc.nextLine sc h[j] = Integer.parseInt(s) h[j] h j Integer.parseInt(s) Integer.parseInt Integer s for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                } j = 0; j = 0 j 0 j < m j m j++ j++ j {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                } {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                } for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    } k = 0; k = 0 k 0 k < h[j] k h[j] h j k++ k++ k {
                        t[k] = w[k];
                    } {
                        t[k] = w[k];
                    } t[k] = w[k] t[k] t k w[k] w k for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    } k = h[j]; k = h[j] k h[j] h j k < wl k wl k++ k++ k {
                        w[k-h[j]] = w[k];
                    } {
                        w[k-h[j]] = w[k];
                    } w[k-h[j]] = w[k] w[k-h[j]] w k-h[j] k h[j] h j w[k] w k for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    } k = wl-h[j]; k = wl-h[j] k wl-h[j] wl h[j] h j k < wl k wl k++ k++ k {
                        w[k] = t[k-wl+h[j]];
                    } {
                        w[k] = t[k-wl+h[j]];
                    } w[k] = t[k-wl+h[j]] w[k] w k t[k-wl+h[j]] t k-wl+h[j] k-wl k wl h[j] h j r[i] = new String(w) r[i] r i new String(w) sc.close() sc.close sc int I = i; I i for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            } i = 0; i = 0 i 0 i < I i I i++ i++ i {
                System.out.println(r[i]);
            } {
                System.out.println(r[i]);
            } System.out.println(r[i]) System.out.println System.out System System.out r[i] r i String[] args args public class Main {
    public static void main (String[] args) {
        try {
            int m, i, j, k, wl;
            Scanner sc = new Scanner(System.in);
            String s;
            String[] r = new String[10];
            char[] t = new char[200];
            int[] h = new int[100];

            for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            }
            sc.close();

            int I = i;

            for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            }
        }
        catch (NumberFormatException e) {
            System.out.println(e);
        }
    }
} public class Main {
    public static void main (String[] args) {
        try {
            int m, i, j, k, wl;
            Scanner sc = new Scanner(System.in);
            String s;
            String[] r = new String[10];
            char[] t = new char[200];
            int[] h = new int[100];

            for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            }
            sc.close();

            int I = i;

            for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            }
        }
        catch (NumberFormatException e) {
            System.out.println(e);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        try {
            int m, i, j, k, wl;
            Scanner sc = new Scanner(System.in);
            String s;
            String[] r = new String[10];
            char[] t = new char[200];
            int[] h = new int[100];

            for (i = 0; true; i++) {
                s = sc.nextLine();
                if (s.equals("-")) break;

                wl = s.length();

                char[] w = new char[wl];

                for (j = 0; j < wl; j++) {
                    w[j] = s.charAt(j);
                }

                s = sc.nextLine();
                m = Integer.parseInt(s);

                for (j = 0; j < m; j++) {
                    s = sc.nextLine();
                    h[j] = Integer.parseInt(s);
                }

                for (j = 0; j < m; j++) {
                    for (k = 0; k < h[j]; k++) {
                        t[k] = w[k];
                    }
                    for (k = h[j]; k < wl; k++) {
                        w[k-h[j]] = w[k];
                    }
                    for (k = wl-h[j]; k < wl; k++) {
                        w[k] = t[k-wl+h[j]];
                    }
                }
                r[i] = new String(w);
            }
            sc.close();

            int I = i;

            for (i = 0; i < I; i++) {
                System.out.println(r[i]);
            }
        }
        catch (NumberFormatException e) {
            System.out.println(e);
        }
    }
}
