import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        for(int k=0;;k++){
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        }
    }
}
 import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        for(int k=0;;k++){
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        }
    }
} Main public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        for(int k=0;;k++){
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        for(int k=0;;k++){
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) for(int k=0;;k++){
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        } int k=0; int k=0; k 0 k++ k++ k {
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        } {
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        } String s1 = sc.next(); s1 sc.next() sc.next sc if(s1.equals("-")) break; s1.equals("-") s1.equals s1 "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            } {
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            } int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc String s2 = s1.substring(h,s1.length()); s2 s1.substring(h,s1.length()) s1.substring s1 h s1.length() s1.length s1 s2 += s1.substring(0,h) s2 s1.substring(0,h) s1.substring s1 0 h s1 = s2 s1 s2 System.out.println(s1) System.out.println System.out System System.out s1 String[]argc argc public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        for(int k=0;;k++){
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        }
    }
} public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        for(int k=0;;k++){
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        }
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        for(int k=0;;k++){
            String s1 = sc.next();
            if(s1.equals("-")) break;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                String s2 = s1.substring(h,s1.length());
                s2 += s1.substring(0,h);
                s1 = s2;
            }
            System.out.println(s1);
        }
    }
}

