
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String w= scanner.next();
            if(w.equals("-")) break;
            long m=scanner.nextLong();
            for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            }
            System.out.println(w);
        }

    }

}
 import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String w= scanner.next();
            if(w.equals("-")) break;
            long m=scanner.nextLong();
            for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            }
            System.out.println(w);
        }

    }

} Main public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String w= scanner.next();
            if(w.equals("-")) break;
            long m=scanner.nextLong();
            for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            }
            System.out.println(w);
        }

    } main {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String w= scanner.next();
            if(w.equals("-")) break;
            long m=scanner.nextLong();
            for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            }
            System.out.println(w);
        }

    } Scanner scanner=new Scanner(System.in); scanner new Scanner(System.in) while(true){
            String w= scanner.next();
            if(w.equals("-")) break;
            long m=scanner.nextLong();
            for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            }
            System.out.println(w);
        } true {
            String w= scanner.next();
            if(w.equals("-")) break;
            long m=scanner.nextLong();
            for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            }
            System.out.println(w);
        } String w= scanner.next(); w scanner.next() scanner.next scanner if(w.equals("-")) break; w.equals("-") w.equals w "-" break; long m=scanner.nextLong(); m scanner.nextLong() scanner.nextLong scanner for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            } {
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            } int h=scanner.nextInt(); h scanner.nextInt() scanner.nextInt scanner w=w.substring(h,w.length())+w.subSequence(0,h) w w.substring(h,w.length())+w.subSequence(0,h) w.substring(h,w.length()) w.substring w h w.length() w.length w w.subSequence(0,h) w.subSequence w 0 h System.out.println(w) System.out.println System.out System System.out w String[] args args public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String w= scanner.next();
            if(w.equals("-")) break;
            long m=scanner.nextLong();
            for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            }
            System.out.println(w);
        }

    }

} public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String w= scanner.next();
            if(w.equals("-")) break;
            long m=scanner.nextLong();
            for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            }
            System.out.println(w);
        }

    }

} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        while(true){
            String w= scanner.next();
            if(w.equals("-")) break;
            long m=scanner.nextLong();
            for(int i=0;i<m;i++){
                int h=scanner.nextInt();
                w=w.substring(h,w.length())+w.subSequence(0,h);
            }
            System.out.println(w);
        }

    }

}

