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

public class Main {
    public static void main(String[] args) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try{
        String line1;
        char[] ch = new char[200000];
        while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        }
      }catch(IOException e){

      }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try{
        String line1;
        char[] ch = new char[200000];
        while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        }
      }catch(IOException e){

      }
    }
} Main public static void main(String[] args) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try{
        String line1;
        char[] ch = new char[200000];
        while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        }
      }catch(IOException e){

      }
    } main {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try{
        String line1;
        char[] ch = new char[200000];
        while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        }
      }catch(IOException e){

      }
    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try{
        String line1;
        char[] ch = new char[200000];
        while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        }
      }catch(IOException e){

      } catch(IOException e){

      } IOException e {

      } {
        String line1;
        char[] ch = new char[200000];
        while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        }
      } String line1; line1 char[] ch = new char[200000]; ch new char[200000] 200000 while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        } !(line1 = reader.readLine()).equals("-") (line1 = reader.readLine()).equals("-") (line1 = reader.readLine()).equals (line1 = reader.readLine()) line1 reader.readLine() reader.readLine reader "-" {
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        } for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             } int i = 0; int i = 0; i 0 i < line1.length() i line1.length() line1.length line1 i++ i++ i {
               ch[i] = line1.charAt(i);
             } {
               ch[i] = line1.charAt(i);
             } ch[i] = line1.charAt(i) ch[i] ch i line1.charAt(i) line1.charAt line1 i int l = 0; l 0 int r = line1.length() - 1; r line1.length() - 1 line1.length() line1.length line1 1 String line2 = reader.readLine(); line2 reader.readLine() reader.readLine reader int m = Integer.parseInt(line2); m Integer.parseInt(line2) Integer.parseInt Integer line2 int[] h = new int[m]; h new int[m] m for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             } {
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             } String line3 = reader.readLine(); line3 reader.readLine() reader.readLine reader h[i] = Integer.parseInt(line3) h[i] h i Integer.parseInt(line3) Integer.parseInt Integer line3 for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               } int j = 0; int j = 0; j 0 j < h[i] j h[i] h i j++ j++ j {
                  ch[r + 1 + j] = ch[l + j];
               } {
                  ch[r + 1 + j] = ch[l + j];
               } ch[r + 1 + j] = ch[l + j] ch[r + 1 + j] ch r + 1 + j r + 1 + j r 1 j ch[l + j] ch l + j l j l += h[i] l h[i] h i r += h[i] r h[i] h i for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             } int i = l; int i = l; i l i <= r i r i++ i++ i {
               System.out.print(ch[i]);
             } {
               System.out.print(ch[i]);
             } System.out.print(ch[i]) System.out.print System.out System System.out ch[i] ch i System.out.println() System.out.println System.out System System.out String[] args args public class Main {
    public static void main(String[] args) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try{
        String line1;
        char[] ch = new char[200000];
        while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        }
      }catch(IOException e){

      }
    }
} public class Main {
    public static void main(String[] args) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try{
        String line1;
        char[] ch = new char[200000];
        while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        }
      }catch(IOException e){

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

public class Main {
    public static void main(String[] args) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try{
        String line1;
        char[] ch = new char[200000];
        while(!(line1 = reader.readLine()).equals("-")){
             for(int i = 0; i < line1.length(); i++){
               ch[i] = line1.charAt(i);
             }
             int l = 0;
             int r = line1.length() - 1;
             String line2 = reader.readLine();
             int m = Integer.parseInt(line2);
             int[] h = new int[m];
             for(int i = 0; i < m; i++){
               String line3 = reader.readLine();
               h[i] = Integer.parseInt(line3);
               for(int j = 0; j < h[i]; j++){
                  ch[r + 1 + j] = ch[l + j];
               }
               l += h[i];
               r += h[i];
             }
             for(int i = l; i <= r; i++){
               System.out.print(ch[i]);
             }
             System.out.println();
        }
      }catch(IOException e){

      }
    }
}
