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

public class Main {

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

        while(true){

            String input = br.readLine();

//          ???????????¶
            if(input.equals("-")){
                break;
            }
//          ?????£??????????????°shuffle
            int shuffle = Integer.parseInt(br.readLine());

            for(int i = 0; i < shuffle; i++){
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            }
            System.out.println(input);
        }
    }
} 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) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){

            String input = br.readLine();

//          ???????????¶
            if(input.equals("-")){
                break;
            }
//          ?????£??????????????°shuffle
            int shuffle = Integer.parseInt(br.readLine());

            for(int i = 0; i < shuffle; i++){
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            }
            System.out.println(input);
        }
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){

            String input = br.readLine();

//          ???????????¶
            if(input.equals("-")){
                break;
            }
//          ?????£??????????????°shuffle
            int shuffle = Integer.parseInt(br.readLine());

            for(int i = 0; i < shuffle; i++){
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            }
            System.out.println(input);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){

            String input = br.readLine();

//          ???????????¶
            if(input.equals("-")){
                break;
            }
//          ?????£??????????????°shuffle
            int shuffle = Integer.parseInt(br.readLine());

            for(int i = 0; i < shuffle; i++){
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            }
            System.out.println(input);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){

            String input = br.readLine();

//          ???????????¶
            if(input.equals("-")){
                break;
            }
//          ?????£??????????????°shuffle
            int shuffle = Integer.parseInt(br.readLine());

            for(int i = 0; i < shuffle; i++){
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            }
            System.out.println(input);
        } true {

            String input = br.readLine();

//          ???????????¶
            if(input.equals("-")){
                break;
            }
//          ?????£??????????????°shuffle
            int shuffle = Integer.parseInt(br.readLine());

            for(int i = 0; i < shuffle; i++){
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            }
            System.out.println(input);
        } String input = br.readLine(); input br.readLine() br.readLine br if(input.equals("-")){
                break;
            } input.equals("-") input.equals input "-" {
                break;
            } break; 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());
                input = input.substring(h) + input.substring(0, h);
            } int i = 0; int i = 0; i 0 i < shuffle i shuffle i++ i++ i {
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            } {
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            } int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br input = input.substring(h) + input.substring(0, h) input input.substring(h) + input.substring(0, h) input.substring(h) input.substring input h input.substring(0, h) input.substring input 0 h System.out.println(input) System.out.println System.out System System.out input String[] args args public class Main {

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

        while(true){

            String input = br.readLine();

//          ???????????¶
            if(input.equals("-")){
                break;
            }
//          ?????£??????????????°shuffle
            int shuffle = Integer.parseInt(br.readLine());

            for(int i = 0; i < shuffle; i++){
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            }
            System.out.println(input);
        }
    }
} public class Main {

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

        while(true){

            String input = br.readLine();

//          ???????????¶
            if(input.equals("-")){
                break;
            }
//          ?????£??????????????°shuffle
            int shuffle = Integer.parseInt(br.readLine());

            for(int i = 0; i < shuffle; i++){
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            }
            System.out.println(input);
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

        while(true){

            String input = br.readLine();

//          ???????????¶
            if(input.equals("-")){
                break;
            }
//          ?????£??????????????°shuffle
            int shuffle = Integer.parseInt(br.readLine());

            for(int i = 0; i < shuffle; i++){
                int h = Integer.parseInt(br.readLine());
                input = input.substring(h) + input.substring(0, h);
            }
            System.out.println(input);
        }
    }
}