/* ITP1_9_B */
import java.io.*;

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

      while((cards = br.readLine()).equals("-") == false){
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      }

    }catch(Exception e){
      System.out.println(e);
    }
  }
} import java.io.*; io.* java class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String cards = "";

      while((cards = br.readLine()).equals("-") == false){
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      }

    }catch(Exception e){
      System.out.println(e);
    }
  }
} Main public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String cards = "";

      while((cards = br.readLine()).equals("-") == false){
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      }

    }catch(Exception e){
      System.out.println(e);
    }
  } main {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String cards = "";

      while((cards = br.readLine()).equals("-") == false){
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      }

    }catch(Exception e){
      System.out.println(e);
    }
  } try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String cards = "";

      while((cards = br.readLine()).equals("-") == false){
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      }

    }catch(Exception e){
      System.out.println(e);
    } catch(Exception e){
      System.out.println(e);
    } Exception e {
      System.out.println(e);
    } System.out.println(e) System.out.println System.out System System.out e {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String cards = "";

      while((cards = br.readLine()).equals("-") == false){
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      }

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String cards = ""; cards "" while((cards = br.readLine()).equals("-") == false){
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      } (cards = br.readLine()).equals("-") == false (cards = br.readLine()).equals("-") (cards = br.readLine()).equals (cards = br.readLine()) cards br.readLine() br.readLine br "-" false {
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      } int shuffle = Integer.parseInt(br.readLine()); shuffle Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        } int i = 0; int i = 0; i 0 i < shuffle i shuffle i++ i++ i {
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        } {
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        } int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br StringBuilder sb = new StringBuilder(); sb new StringBuilder() sb.append(cards.substring(h, cards.length())) sb.append sb cards.substring(h, cards.length()) cards.substring cards h cards.length() cards.length cards sb.append(cards.substring(0, h)) sb.append sb cards.substring(0, h) cards.substring cards 0 h cards = sb.toString() cards sb.toString() sb.toString sb System.out.println(cards) System.out.println System.out System System.out cards String[] args args
/* ITP1_9_B */
import java.io.*;

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

      while((cards = br.readLine()).equals("-") == false){
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      }

    }catch(Exception e){
      System.out.println(e);
    }
  }
}