import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            String Cards = sc.next();
            int i, j;
            int l = Cards.length();
            char w[] = new char[l];
            char R[] = new char[l];
            for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            }
            if(w[0] == '-') break;
            int m = sc.nextInt();
            for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            }
            for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            }
            System.out.printf("\n");
        }
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            String Cards = sc.next();
            int i, j;
            int l = Cards.length();
            char w[] = new char[l];
            char R[] = new char[l];
            for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            }
            if(w[0] == '-') break;
            int m = sc.nextInt();
            for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            }
            for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            }
            System.out.printf("\n");
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            String Cards = sc.next();
            int i, j;
            int l = Cards.length();
            char w[] = new char[l];
            char R[] = new char[l];
            for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            }
            if(w[0] == '-') break;
            int m = sc.nextInt();
            for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            }
            for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            }
            System.out.printf("\n");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String Cards = sc.next();
            int i, j;
            int l = Cards.length();
            char w[] = new char[l];
            char R[] = new char[l];
            for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            }
            if(w[0] == '-') break;
            int m = sc.nextInt();
            for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            }
            for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            }
            System.out.printf("\n");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
            String Cards = sc.next();
            int i, j;
            int l = Cards.length();
            char w[] = new char[l];
            char R[] = new char[l];
            for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            }
            if(w[0] == '-') break;
            int m = sc.nextInt();
            for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            }
            for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            }
            System.out.printf("\n");
        } true {
            String Cards = sc.next();
            int i, j;
            int l = Cards.length();
            char w[] = new char[l];
            char R[] = new char[l];
            for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            }
            if(w[0] == '-') break;
            int m = sc.nextInt();
            for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            }
            for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            }
            System.out.printf("\n");
        } String Cards = sc.next(); Cards sc.next() sc.next sc int i i j; j int l = Cards.length(); l Cards.length() Cards.length Cards char w[] = new char[l]; w new char[l] l char R[] = new char[l]; R new char[l] l for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            } i = 0; i = 0 i 0 i < l i l i++ i++ i {
                w[i] = Cards.charAt(i);
            } {
                w[i] = Cards.charAt(i);
            } w[i] = Cards.charAt(i) w[i] w i Cards.charAt(i) Cards.charAt Cards i if(w[0] == '-') break; w[0] == '-' w[0] w 0 '-' break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            } i = 0; i = 0 i 0 i < m i m i++ i++ i {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            } {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            } int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                } j = 0; j = 0 j 0 j < l j l j++ j++ j {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                } {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                } if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    } j < h j h {
                        R[j] = w[j];
                    } R[j] = w[j] R[j] R j w[j] w j {
                        w[j - h] = w[j];
                    } w[j - h] = w[j] w[j - h] w j - h j h w[j] w j for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                } j = 0; j = 0 j 0 j < h j h j++ j++ j {
                    w[l - h + j] = R[j];
                } {
                    w[l - h + j] = R[j];
                } w[l - h + j] = R[j] w[l - h + j] w l - h + j l - h l h j R[j] R j for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            } i = 0; i = 0 i 0 i < l i l i++ i++ i {
                System.out.printf("%c", w[i]);
            } {
                System.out.printf("%c", w[i]);
            } System.out.printf("%c", w[i]) System.out.printf System.out System System.out "%c" w[i] w i System.out.printf("\n") System.out.printf System.out System System.out "\n" String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            String Cards = sc.next();
            int i, j;
            int l = Cards.length();
            char w[] = new char[l];
            char R[] = new char[l];
            for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            }
            if(w[0] == '-') break;
            int m = sc.nextInt();
            for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            }
            for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            }
            System.out.printf("\n");
        }
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            String Cards = sc.next();
            int i, j;
            int l = Cards.length();
            char w[] = new char[l];
            char R[] = new char[l];
            for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            }
            if(w[0] == '-') break;
            int m = sc.nextInt();
            for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            }
            for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            }
            System.out.printf("\n");
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            String Cards = sc.next();
            int i, j;
            int l = Cards.length();
            char w[] = new char[l];
            char R[] = new char[l];
            for (i = 0; i < l; i++) {
                w[i] = Cards.charAt(i);
            }
            if(w[0] == '-') break;
            int m = sc.nextInt();
            for (i = 0; i < m; i++) {
                int h = sc.nextInt();
                for (j = 0; j < l; j++) {
                    if (j < h) {
                        R[j] = w[j];
                    } else {
                        w[j - h] = w[j];
                    }
                }
                for (j = 0; j < h; j++) {
                    w[l - h + j] = R[j];
                }
            }
            for (i = 0; i < l; i++) {
                System.out.printf("%c", w[i]);
            }
            System.out.printf("\n");
        }
    }
}

