import java.util.Scanner;
import java.io.*;

class Main {
    public static void main(String[] args)throws IOException{ 
    	InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
    	   	                                                 
    	while(true){
        String trump = reader.readLine();
            if(trump.equals("-")){
            break;
            }

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

            for(int H = 0; H < m; H++){
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            }
            System.out.println(trump);
        }
    }
} import java.util.Scanner; Scanner java.util import java.io.*; io.* java class Main {
    public static void main(String[] args)throws IOException{ 
    	InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
    	   	                                                 
    	while(true){
        String trump = reader.readLine();
            if(trump.equals("-")){
            break;
            }

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

            for(int H = 0; H < m; H++){
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            }
            System.out.println(trump);
        }
    }
} Main public static void main(String[] args)throws IOException{ 
    	InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
    	   	                                                 
    	while(true){
        String trump = reader.readLine();
            if(trump.equals("-")){
            break;
            }

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

            for(int H = 0; H < m; H++){
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            }
            System.out.println(trump);
        }
    } main { 
    	InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
    	   	                                                 
    	while(true){
        String trump = reader.readLine();
            if(trump.equals("-")){
            break;
            }

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

            for(int H = 0; H < m; H++){
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            }
            System.out.println(trump);
        }
    } InputStreamReader in = new InputStreamReader(System.in); in new InputStreamReader(System.in) BufferedReader reader = new BufferedReader(in); reader new BufferedReader(in) while(true){
        String trump = reader.readLine();
            if(trump.equals("-")){
            break;
            }

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

            for(int H = 0; H < m; H++){
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            }
            System.out.println(trump);
        } true {
        String trump = reader.readLine();
            if(trump.equals("-")){
            break;
            }

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

            for(int H = 0; H < m; H++){
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            }
            System.out.println(trump);
        } String trump = reader.readLine(); trump reader.readLine() reader.readLine reader if(trump.equals("-")){
            break;
            } trump.equals("-") trump.equals trump "-" {
            break;
            } break; int m = Integer.parseInt(reader.readLine()); m Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader for(int H = 0; H < m; H++){
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            } int H = 0; int H = 0; H 0 H < m H m H++ H++ H {
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            } {
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            } int h = Integer.parseInt(reader.readLine()); h Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader String left = trump.substring(0, h); left trump.substring(0, h) trump.substring trump 0 h String right = trump.substring(h, trump.length()); right trump.substring(h, trump.length()) trump.substring trump h trump.length() trump.length trump trump = right + left trump right + left right left System.out.println(trump) System.out.println System.out System System.out trump String[] args args
import java.util.Scanner;
import java.io.*;

class Main {
    public static void main(String[] args)throws IOException{ 
    	InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
    	   	                                                 
    	while(true){
        String trump = reader.readLine();
            if(trump.equals("-")){
            break;
            }

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

            for(int H = 0; H < m; H++){
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            }
            System.out.println(trump);
        }
    }
}