import java.util.Scanner;
import java.util.ArrayList;
import java.io.*;

public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    while(true){
      String S=sc.next();
      //System.out.println(S);
      if(S.equals("-")){
        break;
      }else{
      char[] c = S.toCharArray();
      int m = sc.nextInt();
      for(int i=0;i<m;i++){
      int h= sc.nextInt();
        for(int j=0;j<h;j++){
          char[] temp = new char[h];
          temp[j] = c[0];
          //System.out.println(temp[j]);
          for(int k=1;k<c.length;k++){
            c[k-1]=c[k];
            //System.out.print(c[k]);
          }
          c[c.length-1]=temp[j];
          //System.out.println(c[c.length-1]);
      }
      }
       for(int l=0;l<c.length;l++){
       System.out.print(c[l]);
      }
      System.out.println();
     }
  }
 }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz