import java.util.Scanner;

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

 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m,h;
          
        while(true){
            String c = sc.next();
            if(c.equals("-"))
                break;
              
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m,h;
          
        while(true){
            String c = sc.next();
            if(c.equals("-"))
                break;
              
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int m,h;
          
        while(true){
            String c = sc.next();
            if(c.equals("-"))
                break;
              
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int m m h; h while(true){
            String c = sc.next();
            if(c.equals("-"))
                break;
              
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        } true {
            String c = sc.next();
            if(c.equals("-"))
                break;
              
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        } String c = sc.next(); c sc.next() sc.next sc if(c.equals("-"))
                break; c.equals("-") c.equals c "-" break; m = sc.nextInt() m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            } {
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            } h = sc.nextInt() h sc.nextInt() sc.nextInt sc String head=c.substring(0,h); head c.substring(0,h) c.substring c 0 h String tail=c.substring(h); tail c.substring(h) c.substring c h c=tail + head c tail + head tail head 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 sc = new Scanner(System.in);
        int m,h;
          
        while(true){
            String c = sc.next();
            if(c.equals("-"))
                break;
              
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m,h;
          
        while(true){
            String c = sc.next();
            if(c.equals("-"))
                break;
              
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        }
    }
} Main
import java.util.Scanner;

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


