import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int h;
        int i;
        while(!(s=sc.next()).equals("-")){
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int h;
        int i;
        while(!(s=sc.next()).equals("-")){
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        }
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int h;
        int i;
        while(!(s=sc.next()).equals("-")){
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        }
    } main {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int h;
        int i;
        while(!(s=sc.next()).equals("-")){
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        }
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String s; s int m; m int h; h int i; i while(!(s=sc.next()).equals("-")){
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        } !(s=sc.next()).equals("-") (s=sc.next()).equals("-") (s=sc.next()).equals (s=sc.next()) s sc.next() sc.next sc "-" {
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        } m=sc.nextInt() m sc.nextInt() sc.nextInt sc for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            } i=0; i=0 i 0 i<m i m i++ i++ i {
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            } {
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            } h=sc.nextInt() h sc.nextInt() sc.nextInt sc s=s.substring(h,s.length())+s.substring(0,h) s s.substring(h,s.length())+s.substring(0,h) s.substring(h,s.length()) s.substring s h s.length() s.length s s.substring(0,h) s.substring s 0 h System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int h;
        int i;
        while(!(s=sc.next()).equals("-")){
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int h;
        int i;
        while(!(s=sc.next()).equals("-")){
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int h;
        int i;
        while(!(s=sc.next()).equals("-")){
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        }
    }
}
