import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while(true){
 
            String s=sc.nextLine();
            if("-".equals(s))break;
            int count=sc.nextInt();
            for(int i=0;i<count;i++){
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            }sc.nextLine();
            ln(s);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}
 import java.util.Scanner; Scanner java.util class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while(true){
 
            String s=sc.nextLine();
            if("-".equals(s))break;
            int count=sc.nextInt();
            for(int i=0;i<count;i++){
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            }sc.nextLine();
            ln(s);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public void run() {
        while(true){
 
            String s=sc.nextLine();
            if("-".equals(s))break;
            int count=sc.nextInt();
            for(int i=0;i<count;i++){
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            }sc.nextLine();
            ln(s);
        }
    } run {
        while(true){
 
            String s=sc.nextLine();
            if("-".equals(s))break;
            int count=sc.nextInt();
            for(int i=0;i<count;i++){
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            }sc.nextLine();
            ln(s);
        }
    } while(true){
 
            String s=sc.nextLine();
            if("-".equals(s))break;
            int count=sc.nextInt();
            for(int i=0;i<count;i++){
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            }sc.nextLine();
            ln(s);
        } true {
 
            String s=sc.nextLine();
            if("-".equals(s))break;
            int count=sc.nextInt();
            for(int i=0;i<count;i++){
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            }sc.nextLine();
            ln(s);
        } String s=sc.nextLine(); s sc.nextLine() sc.nextLine sc if("-".equals(s))break; "-".equals(s) "-".equals "-" s break; int count=sc.nextInt(); count sc.nextInt() sc.nextInt sc for(int i=0;i<count;i++){
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            } int i=0; int i=0; i 0 i<count i count i++ i++ i {
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            } {
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            } int index=sc.nextInt(); index sc.nextInt() sc.nextInt sc s=s.substring(index)+s.substring(0,index) s s.substring(index)+s.substring(0,index) s.substring(index) s.substring s index s.substring(0,index) s.substring s 0 index sc.nextLine() sc.nextLine sc ln(s) ln s public static void main(String[] args) {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args public static void pr(Object o) {
        System.out.print(o);
    } pr {
        System.out.print(o);
    } System.out.print(o) System.out.print System.out System System.out o Object o o public static void ln(Object o) {
        System.out.println(o);
    } ln {
        System.out.println(o);
    } System.out.println(o) System.out.println System.out System System.out o Object o o public static void ln() {
        System.out.println();
    } ln {
        System.out.println();
    } System.out.println() System.out.println System.out System System.out
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while(true){
 
            String s=sc.nextLine();
            if("-".equals(s))break;
            int count=sc.nextInt();
            for(int i=0;i<count;i++){
                int index=sc.nextInt();
                s=s.substring(index)+s.substring(0,index);
            }sc.nextLine();
            ln(s);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}

