

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



   while(true){

	  String cards =  br.readLine();
	  if( cards.equals("-") )  break;

      int m = Integer.parseInt(br.readLine());

      for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      }
      System.out.println(cards);

   }



  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



   while(true){

	  String cards =  br.readLine();
	  if( cards.equals("-") )  break;

      int m = Integer.parseInt(br.readLine());

      for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      }
      System.out.println(cards);

   }



  }
} Main public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



   while(true){

	  String cards =  br.readLine();
	  if( cards.equals("-") )  break;

      int m = Integer.parseInt(br.readLine());

      for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      }
      System.out.println(cards);

   }



  } main {
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



   while(true){

	  String cards =  br.readLine();
	  if( cards.equals("-") )  break;

      int m = Integer.parseInt(br.readLine());

      for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      }
      System.out.println(cards);

   }



  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){

	  String cards =  br.readLine();
	  if( cards.equals("-") )  break;

      int m = Integer.parseInt(br.readLine());

      for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      }
      System.out.println(cards);

   } true {

	  String cards =  br.readLine();
	  if( cards.equals("-") )  break;

      int m = Integer.parseInt(br.readLine());

      for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      }
      System.out.println(cards);

   } String cards =  br.readLine(); cards br.readLine() br.readLine br if( cards.equals("-") )  break; cards.equals("-") cards.equals cards "-" break; int m = Integer.parseInt(br.readLine()); m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      } {
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      } int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br String left = cards.substring(0, h); left cards.substring(0, h) cards.substring cards 0 h String right = cards.substring(h, cards.length()); right cards.substring(h, cards.length()) cards.substring cards h cards.length() cards.length cards cards = right + left cards right + left right left System.out.println(cards) System.out.println System.out System System.out cards String args[] args


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



   while(true){

	  String cards =  br.readLine();
	  if( cards.equals("-") )  break;

      int m = Integer.parseInt(br.readLine());

      for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      }
      System.out.println(cards);

   }



  }
}