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

        while(true){
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int num = str.length(),m = sc.nextInt(),h;
            String ar[] =str.split(""),ex[]=new String[num];
            for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            }
            for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            }
            System.out.print("\n");
        }

        sc.close();
    }
}
 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 str = sc.next();
            if(str.equals("-")){
                break;
            }
            int num = str.length(),m = sc.nextInt(),h;
            String ar[] =str.split(""),ex[]=new String[num];
            for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            }
            for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            }
            System.out.print("\n");
        }

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

        while(true){
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int num = str.length(),m = sc.nextInt(),h;
            String ar[] =str.split(""),ex[]=new String[num];
            for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            }
            for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            }
            System.out.print("\n");
        }

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        while(true){
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int num = str.length(),m = sc.nextInt(),h;
            String ar[] =str.split(""),ex[]=new String[num];
            for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            }
            for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            }
            System.out.print("\n");
        }

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int num = str.length(),m = sc.nextInt(),h;
            String ar[] =str.split(""),ex[]=new String[num];
            for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            }
            for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            }
            System.out.print("\n");
        } true {
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int num = str.length(),m = sc.nextInt(),h;
            String ar[] =str.split(""),ex[]=new String[num];
            for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            }
            for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            }
            System.out.print("\n");
        } String str = sc.next(); str sc.next() sc.next sc if(str.equals("-")){
                break;
            } str.equals("-") str.equals str "-" {
                break;
            } break; int num = str.length() num str.length() str.length str m = sc.nextInt() m sc.nextInt() sc.nextInt sc h; h String ar[] =str.split("") ar str.split("") str.split str "" ex[]=new String[num]; ex new String[num] num for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            } {
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            } h=sc.nextInt() h sc.nextInt() sc.nextInt sc for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                } int j=0; int j=0; j 0 j<h j h j++ j++ j {
                    ex[j]=ar[j];
                } {
                    ex[j]=ar[j];
                } ex[j]=ar[j] ex[j] ex j ar[j] ar j for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                } int l=h; int l=h; l h l<num l num l++ l++ l {
                    ar[l-h]=ar[l];
                } {
                    ar[l-h]=ar[l];
                } ar[l-h]=ar[l] ar[l-h] ar l-h l h ar[l] ar l for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                } int k=0; int k=0; k 0 k<h k h k++ k++ k {
                    ar[k+(num-h)]=ex[k];
                } {
                    ar[k+(num-h)]=ex[k];
                } ar[k+(num-h)]=ex[k] ar[k+(num-h)] ar k+(num-h) k (num-h) num h ex[k] ex k for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            } int r=0; int r=0; r 0 r<num r num r++ r++ r {
                System.out.print(ar[r]);
            } {
                System.out.print(ar[r]);
            } System.out.print(ar[r]) System.out.print System.out System System.out ar[r] ar r System.out.print("\n") System.out.print System.out System System.out "\n" sc.close() sc.close sc String[] args args public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true){
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int num = str.length(),m = sc.nextInt(),h;
            String ar[] =str.split(""),ex[]=new String[num];
            for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            }
            for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            }
            System.out.print("\n");
        }

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

        while(true){
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int num = str.length(),m = sc.nextInt(),h;
            String ar[] =str.split(""),ex[]=new String[num];
            for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            }
            for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            }
            System.out.print("\n");
        }

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

        while(true){
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int num = str.length(),m = sc.nextInt(),h;
            String ar[] =str.split(""),ex[]=new String[num];
            for(int i=0;i<m;i++){
                h=sc.nextInt();
                for(int j=0;j<h;j++){
                    ex[j]=ar[j];
                }
                for(int l=h;l<num;l++){
                    ar[l-h]=ar[l];
                }
                for(int k=0;k<h;k++){
                    ar[k+(num-h)]=ex[k];
                }
            }
            for(int r=0;r<num;r++){
                System.out.print(ar[r]);
            }
            System.out.print("\n");
        }

        sc.close();
    }
}

