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("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[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("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[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("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[k]);

    }
    System.out.println("");



      }


    } main {
        Scanner sc =new Scanner(System.in);
      while (true) {
          
            String line = sc.next();
            if(line.equals("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[k]);

    }
    System.out.println("");



      }


    } Scanner sc =new Scanner(System.in); sc new Scanner(System.in) while (true) {
          
            String line = sc.next();
            if(line.equals("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[k]);

    }
    System.out.println("");



      } true {
          
            String line = sc.next();
            if(line.equals("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[k]);

    }
    System.out.println("");



      } String line = sc.next(); line sc.next() sc.next sc if(line.equals("-")) {
                break;
            } line.equals("-") line.equals line "-" {
                break;
            } break; int n = line.length(); n line.length() line.length line char[] str = new char[n]; str new char[n] n for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                str[i] = line.charAt(i);

            } {
                str[i] = line.charAt(i);

            } str[i] = line.charAt(i) str[i] str 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++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       } int i=0; int i=0; i 0 i<m i m i++ i++ i {
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       } {
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       } int h=sc.nextInt(); h sc.nextInt() sc.nextInt sc char hoge[]=new char[n]; hoge new char[n] n System.arraycopy(str, 0, hoge,0, n) System.arraycopy System str 0 hoge 0 n for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            } int j=0; int j=0; j 0 j<n j n j++ j++ j {

                str[j]=hoge[(j+h)%n];

            } {

                str[j]=hoge[(j+h)%n];

            } str[j]=hoge[(j+h)%n] str[j] str j hoge[(j+h)%n] hoge (j+h)%n (j+h) j h n for(int k=0;k<n;k++){
        System.out.print(str[k]);

    } int k=0; int k=0; k 0 k<n k n k++ k++ k {
        System.out.print(str[k]);

    } {
        System.out.print(str[k]);

    } System.out.print(str[k]) System.out.print System.out System System.out str[k] str 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("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[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("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[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("-")) {
                break;
            };
            int n = line.length();
            char[] str = new char[n];
            for(int i=0;i<n;i++){
                str[i] = line.charAt(i);

            }
        int m=sc.nextInt();
       for(int i=0;i<m;i++){
           int h=sc.nextInt();
           char hoge[]=new char[n];

           System.arraycopy(str, 0, hoge,0, n);
            for(int j=0;j<n;j++){

                str[j]=hoge[(j+h)%n];

            }
          
       }
       for(int k=0;k<n;k++){
        System.out.print(str[k]);

    }
    System.out.println("");



      }


    }
}
