import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    }

    private static void execute(BufferedReader br) throws Exception {
        while (true) {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        }
    }

    private static String shuffle(String str, int n) {
        String fromInitialsToN = str.substring(0, n);
        String fromN1ToEnd = str.substring(n, str.length());
        return fromN1ToEnd + fromInitialsToN;
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    }

    private static void execute(BufferedReader br) throws Exception {
        while (true) {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        }
    }

    private static String shuffle(String str, int n) {
        String fromInitialsToN = str.substring(0, n);
        String fromN1ToEnd = str.substring(n, str.length());
        return fromN1ToEnd + fromInitialsToN;
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) execute(br) execute br String[] args args private static void execute(BufferedReader br) throws Exception {
        while (true) {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        }
    } execute {
        while (true) {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        }
    } while (true) {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        } true {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        } String str = br.readLine(); str br.readLine() br.readLine br if (str.equals("-")) { break; } str.equals("-") str.equals str "-" { break; } break; int m = Integer.parseInt(br.readLine()); m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            } {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            } int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br str = shuffle(str, n) str shuffle(str, n) shuffle str n System.out.println(str) System.out.println System.out System System.out str BufferedReader br br private static String shuffle(String str, int n) {
        String fromInitialsToN = str.substring(0, n);
        String fromN1ToEnd = str.substring(n, str.length());
        return fromN1ToEnd + fromInitialsToN;
    } shuffle {
        String fromInitialsToN = str.substring(0, n);
        String fromN1ToEnd = str.substring(n, str.length());
        return fromN1ToEnd + fromInitialsToN;
    } String fromInitialsToN = str.substring(0, n); fromInitialsToN str.substring(0, n) str.substring str 0 n String fromN1ToEnd = str.substring(n, str.length()); fromN1ToEnd str.substring(n, str.length()) str.substring str n str.length() str.length str return fromN1ToEnd + fromInitialsToN; fromN1ToEnd + fromInitialsToN fromN1ToEnd fromInitialsToN String str str int n n public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    }

    private static void execute(BufferedReader br) throws Exception {
        while (true) {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        }
    }

    private static String shuffle(String str, int n) {
        String fromInitialsToN = str.substring(0, n);
        String fromN1ToEnd = str.substring(n, str.length());
        return fromN1ToEnd + fromInitialsToN;
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    }

    private static void execute(BufferedReader br) throws Exception {
        while (true) {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        }
    }

    private static String shuffle(String str, int n) {
        String fromInitialsToN = str.substring(0, n);
        String fromN1ToEnd = str.substring(n, str.length());
        return fromN1ToEnd + fromInitialsToN;
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    }

    private static void execute(BufferedReader br) throws Exception {
        while (true) {
            String str = br.readLine();
            if (str.equals("-")) { break; }
            int m = Integer.parseInt(br.readLine());
            for (int i = 0; i < m; i++) {
                int n = Integer.parseInt(br.readLine());
                str = shuffle(str, n);
            }
            System.out.println(str);
        }
    }

    private static String shuffle(String str, int n) {
        String fromInitialsToN = str.substring(0, n);
        String fromN1ToEnd = str.substring(n, str.length());
        return fromN1ToEnd + fromInitialsToN;
    }
}