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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true){
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        }
    }
} import java.io.IOException; IOException java.io import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true){
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        }
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true){
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true){
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (true){
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        } true {
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        } sb.delete(0,sb.length()) sb.delete sb 0 sb.length() sb.length sb String line = br.readLine(); line br.readLine() br.readLine br sb.append(line) sb.append sb line if (line.equals("-")) break; line.equals("-") line.equals line "-" 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 hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            } {
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            } int hi = Integer.parseInt(br.readLine()); hi Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br sb.append(sb.substring(0,hi)) sb.append sb sb.substring(0,hi) sb.substring sb 0 hi sb.delete(0,hi) sb.delete sb 0 hi System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true){
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        }
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true){
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        }
    }
} Main
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true){
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        }
    }
}