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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        StringBuilder sb = new StringBuilder();
        while(!(str = br.readLine()).equals("-")){
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        }
        System.out.print(sb);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException 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));
        String str;
        StringBuilder sb = new StringBuilder();
        while(!(str = br.readLine()).equals("-")){
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        }
        System.out.print(sb);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        StringBuilder sb = new StringBuilder();
        while(!(str = br.readLine()).equals("-")){
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        }
        System.out.print(sb);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        StringBuilder sb = new StringBuilder();
        while(!(str = br.readLine()).equals("-")){
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        }
        System.out.print(sb);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(!(str = br.readLine()).equals("-")){
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        } !(str = br.readLine()).equals("-") (str = br.readLine()).equals("-") (str = br.readLine()).equals (str = br.readLine()) str br.readLine() br.readLine br "-" {
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        } int m = Integer.parseInt(br.readLine()); m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            } m-->0 m-- m 0 {
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            } int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br str = str.substring(h) + str.substring(0,h) str str.substring(h) + str.substring(0,h) str.substring(h) str.substring str h str.substring(0,h) str.substring str 0 h sb.append(str).append("\n") sb.append(str).append sb.append(str) sb.append sb str "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        StringBuilder sb = new StringBuilder();
        while(!(str = br.readLine()).equals("-")){
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        }
        System.out.print(sb);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        StringBuilder sb = new StringBuilder();
        while(!(str = br.readLine()).equals("-")){
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        }
        System.out.print(sb);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        StringBuilder sb = new StringBuilder();
        while(!(str = br.readLine()).equals("-")){
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        }
        System.out.print(sb);
    }
}