import java.util.Scanner;
  
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int m,i,h;
          
        while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int m,i,h;
          
        while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        }
    }
} Main public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int m,i,h;
          
        while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        }
    } main {
        Scanner stdIn = new Scanner(System.in);
        int m,i,h;
          
        while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        }
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int m m i i h; h while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        } true {
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        } String c = stdIn.next(); c stdIn.next() stdIn.next stdIn if(c.equals("-"))
                break; c.equals("-") c.equals c "-" break; m = stdIn.nextInt() m stdIn.nextInt() stdIn.nextInt stdIn for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            } i=0; i=0 i 0 i<m i m i++ i++ i {
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            } {
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            } h = stdIn.nextInt() h stdIn.nextInt() stdIn.nextInt stdIn String t=c.substring(0,h); t c.substring(0,h) c.substring c 0 h c=c.substring(h,c.length())+t c c.substring(h,c.length())+t c.substring(h,c.length()) c.substring c h c.length() c.length c t System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int m,i,h;
          
        while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int m,i,h;
          
        while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        }
    }
} Main
import java.util.Scanner;
  
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int m,i,h;
          
        while(true){
            String c = stdIn.next();
            if(c.equals("-"))
                break;
              
            m = stdIn.nextInt();
            for(i=0;i<m;i++){
                h = stdIn.nextInt();
                String t=c.substring(0,h);
                c=c.substring(h,c.length())+t;
            }
            System.out.println(c);
        }
    }
}
