import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
         
        Scanner sc = new Scanner(System.in);
        String card;
        int m = 0;
        int h = 0;
        int sum = 0;
        String ans1 = "";
        String ans2 = "";
        
        while( true ){
            
            card = sc.next();
            
             if(card.equals("-")) break;
            
            m = sc.nextInt();
                
            for(int i=0;i<m;i++){
                
                h = sc.nextInt();
                
                sum += h;
                
            }
            
          while( true ){
              if(sum>=card.length()){
                  sum-=card.length();
              }else{
                  break;
              }
              
          }
            ans2 = card.substring(sum);
               ans1 = card.substring(0,sum);
               System.out.println(ans2 + ans1);
            
            sum = 0;
            
         }
        sc.close();
    }
}

/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