import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      int n;
      int h;
      
      while(true){
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      }
   }//main
   
   
}//class import java.util.*; util.* java import java.text.*; text.* java public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      int n;
      int h;
      
      while(true){
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      }
   }//main
   
   
}//class Main public static final String EOF = "END_OF_TEXT"; EOF "END_OF_TEXT" public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      int n;
      int h;
      
      while(true){
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      }
   }//main main {
      Scanner sc = new Scanner(System.in);
      String str;
      int n;
      int h;
      
      while(true){
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      }
   } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str; str int n; n int h; h while(true){
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      } true {
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      } str = sc.nextLine() str sc.nextLine() sc.nextLine sc if(str.equals("-")){
            break;
         } str.equals("-") str.equals str "-" {
            break;
         } break; n = Integer.parseInt(sc.nextLine()) n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         } n > 0 n 0 {
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         } h = Integer.parseInt(sc.nextLine()) h Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc str = str.substring(h) + str.substring(0,h) str str.substring(h) + str.substring(0,h) str.substring(h) str.substring str h str.substring(0,h) str.substring str 0 h n-- n System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      int n;
      int h;
      
      while(true){
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      }
   }//main
   
   
}//class public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      int n;
      int h;
      
      while(true){
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      }
   }//main
   
   
}//class Main
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      int n;
      int h;
      
      while(true){
         str = sc.nextLine();
         if(str.equals("-")){
            break;
         }
         n = Integer.parseInt(sc.nextLine());
         
         while(n > 0){
            h = Integer.parseInt(sc.nextLine());
            str = str.substring(h) + str.substring(0,h);
            n--;
         }
         System.out.println(str);
      }
   }//main
   
   
}//class
