// ITP1_9_B Shuffle
import java.io.*;

class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         String cards = br.readLine();
         while (!(cards.equals("-"))) {
            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);
            cards = br.readLine();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
} import java.io.*; io.* java class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         String cards = br.readLine();
         while (!(cards.equals("-"))) {
            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);
            cards = br.readLine();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
} Main public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         String cards = br.readLine();
         while (!(cards.equals("-"))) {
            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);
            cards = br.readLine();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   } main {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         String cards = br.readLine();
         while (!(cards.equals("-"))) {
            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);
            cards = br.readLine();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
         String cards = br.readLine();
         while (!(cards.equals("-"))) {
            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);
            cards = br.readLine();
         }
      }

      catch (Exception e) {
         System.err.println(e);
      } catch (Exception e) {
         System.err.println(e);
      } Exception e {
         System.err.println(e);
      } System.err.println(e) System.err.println System.err System System.err e {
         String cards = br.readLine();
         while (!(cards.equals("-"))) {
            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);
            cards = br.readLine();
         }
      } String cards = br.readLine(); cards br.readLine() br.readLine br while (!(cards.equals("-"))) {
            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);
            cards = br.readLine();
         } !(cards.equals("-")) (cards.equals("-")) cards.equals cards "-" {
            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);
            cards = br.readLine();
         } 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 cards = br.readLine() cards br.readLine() br.readLine br String[] args args
// ITP1_9_B Shuffle
import java.io.*;

class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         String cards = br.readLine();
         while (!(cards.equals("-"))) {
            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);
            cards = br.readLine();
         }
      }

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