import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        }
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        }
    } main {
        Scanner sc = new Scanner(System.in);

        while(true){
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        } true {
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        } String line = sc.next(); line sc.next() sc.next sc if(line.equals("-")) System.exit(0); line.equals("-") line.equals line "-" System.exit(0) System.exit System 0 int l = line.length(); l line.length() line.length line char[] moji = new char[l]; moji new char[l] l for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            } int i=0; int i=0; i 0 i<l i l i++ i++ i {
                moji[i] = line.charAt(i);
            } {
                moji[i] = line.charAt(i);
            } moji[i] = line.charAt(i) moji[i] moji i line.charAt(i) line.charAt line i int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            } {
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            } char[] moji2 = new char[l]; moji2 new char[l] l int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                } int j=0; int j=0; j 0 j<l-h j l-h l h j++ j++ j {
                    moji2[j] = moji[h+j];
                } {
                    moji2[j] = moji[h+j];
                } moji2[j] = moji[h+j] moji2[j] moji2 j moji[h+j] moji h+j h j for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                } int j=0; int j=0; j 0 j<h j h j++ j++ j {
                    moji2[l-h+j] = moji[j];
                } {
                    moji2[l-h+j] = moji[j];
                } moji2[l-h+j] = moji[j] moji2[l-h+j] moji2 l-h+j l-h l h j moji[j] moji j for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                } int j=0; int j=0; j 0 j<l j l j++ j++ j {
                    moji[j] = moji2[j];
                } {
                    moji[j] = moji2[j];
                } moji[j] = moji2[j] moji[j] moji j moji2[j] moji2 j for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            } int k=0; int k=0; k 0 k<l k l k++ k++ k {
                System.out.print(moji[k]);
            } {
                System.out.print(moji[k]);
            } System.out.print(moji[k]) System.out.print System.out System System.out moji[k] moji k System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        }
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            String line = sc.next();
            if(line.equals("-")) System.exit(0);
            int l = line.length();
            char[] moji = new char[l];
            for(int i=0;i<l;i++){
                moji[i] = line.charAt(i);
            }

            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                char[] moji2 = new char[l];
                int h = sc.nextInt();
                for(int j=0;j<l-h;j++){
                    moji2[j] = moji[h+j];
                }
                for(int j=0;j<h;j++){
                    moji2[l-h+j] = moji[j];
                }
                for(int j=0;j<l;j++){
                    moji[j] = moji2[j];
                }
            }
            for(int k=0;k<l;k++){
                System.out.print(moji[k]);
            }
            System.out.println("");
        }
    }
}
