import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        //String str;

        while (true) {
            String str = sc.nextLine();
            String newstr = "";
            if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int m = sc.nextInt();
            int h = 0;
            for (int i=0; i<m; i++) {
                h += sc.nextInt();
            }
            while (h > str.length()) {
                h -= str.length();
            }
            for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            }
            for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            }
            A.add(newstr);
            String dummy = sc.nextLine();
        }

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        //String str;

        while (true) {
            String str = sc.nextLine();
            String newstr = "";
            if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int m = sc.nextInt();
            int h = 0;
            for (int i=0; i<m; i++) {
                h += sc.nextInt();
            }
            while (h > str.length()) {
                h -= str.length();
            }
            for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            }
            for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            }
            A.add(newstr);
            String dummy = sc.nextLine();
        }

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        //String str;

        while (true) {
            String str = sc.nextLine();
            String newstr = "";
            if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int m = sc.nextInt();
            int h = 0;
            for (int i=0; i<m; i++) {
                h += sc.nextInt();
            }
            while (h > str.length()) {
                h -= str.length();
            }
            for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            }
            for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            }
            A.add(newstr);
            String dummy = sc.nextLine();
        }

    } main {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        //String str;

        while (true) {
            String str = sc.nextLine();
            String newstr = "";
            if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int m = sc.nextInt();
            int h = 0;
            for (int i=0; i<m; i++) {
                h += sc.nextInt();
            }
            while (h > str.length()) {
                h -= str.length();
            }
            for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            }
            for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            }
            A.add(newstr);
            String dummy = sc.nextLine();
        }

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<String> A = new ArrayList<String>(); A new ArrayList<String>() while (true) {
            String str = sc.nextLine();
            String newstr = "";
            if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int m = sc.nextInt();
            int h = 0;
            for (int i=0; i<m; i++) {
                h += sc.nextInt();
            }
            while (h > str.length()) {
                h -= str.length();
            }
            for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            }
            for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            }
            A.add(newstr);
            String dummy = sc.nextLine();
        } true {
            String str = sc.nextLine();
            String newstr = "";
            if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int m = sc.nextInt();
            int h = 0;
            for (int i=0; i<m; i++) {
                h += sc.nextInt();
            }
            while (h > str.length()) {
                h -= str.length();
            }
            for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            }
            for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            }
            A.add(newstr);
            String dummy = sc.nextLine();
        } String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc String newstr = ""; newstr "" if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            } str.equals("-") str.equals str "-" {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            } for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                } int i=0; int i=0; i 0 i<A.size() i A.size() A.size A i++ i++ i {
                    System.out.println(A.get(i));
                } {
                    System.out.println(A.get(i));
                } System.out.println(A.get(i)) System.out.println System.out System System.out A.get(i) A.get A i break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int h = 0; h 0 for (int i=0; i<m; i++) {
                h += sc.nextInt();
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                h += sc.nextInt();
            } {
                h += sc.nextInt();
            } h += sc.nextInt() h sc.nextInt() sc.nextInt sc while (h > str.length()) {
                h -= str.length();
            } h > str.length() h str.length() str.length str {
                h -= str.length();
            } h -= str.length() h str.length() str.length str for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            } int i=h; int i=h; i h i<str.length() i str.length() str.length str i++ i++ i {
                newstr += str.substring(i, i+1);
            } {
                newstr += str.substring(i, i+1);
            } newstr += str.substring(i, i+1) newstr str.substring(i, i+1) str.substring str i i+1 i 1 for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            } int i=0; int i=0; i 0 i<h i h i++ i++ i {
                newstr += str.substring(i, i+1);
            } {
                newstr += str.substring(i, i+1);
            } newstr += str.substring(i, i+1) newstr str.substring(i, i+1) str.substring str i i+1 i 1 A.add(newstr) A.add A newstr String dummy = sc.nextLine(); dummy sc.nextLine() sc.nextLine sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        //String str;

        while (true) {
            String str = sc.nextLine();
            String newstr = "";
            if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int m = sc.nextInt();
            int h = 0;
            for (int i=0; i<m; i++) {
                h += sc.nextInt();
            }
            while (h > str.length()) {
                h -= str.length();
            }
            for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            }
            for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            }
            A.add(newstr);
            String dummy = sc.nextLine();
        }

    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        //String str;

        while (true) {
            String str = sc.nextLine();
            String newstr = "";
            if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int m = sc.nextInt();
            int h = 0;
            for (int i=0; i<m; i++) {
                h += sc.nextInt();
            }
            while (h > str.length()) {
                h -= str.length();
            }
            for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            }
            for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            }
            A.add(newstr);
            String dummy = sc.nextLine();
        }

    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        //String str;

        while (true) {
            String str = sc.nextLine();
            String newstr = "";
            if (str.equals("-")) {
                for (int i=0; i<A.size(); i++) {
                    System.out.println(A.get(i));
                }
                break;
            }
            int m = sc.nextInt();
            int h = 0;
            for (int i=0; i<m; i++) {
                h += sc.nextInt();
            }
            while (h > str.length()) {
                h -= str.length();
            }
            for (int i=h; i<str.length(); i++) {
                newstr += str.substring(i, i+1);
            }
            for (int i=0; i<h; i++) {
                newstr += str.substring(i, i+1);
            }
            A.add(newstr);
            String dummy = sc.nextLine();
        }

    }
}
