import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String input = sc.next();

        while(!(input.equals("-"))){
            int time = sc.nextInt();
            for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            }
            System.out.println(input);
            input = sc.next();
        }
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String input = sc.next();

        while(!(input.equals("-"))){
            int time = sc.nextInt();
            for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            }
            System.out.println(input);
            input = sc.next();
        }
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String input = sc.next();

        while(!(input.equals("-"))){
            int time = sc.nextInt();
            for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            }
            System.out.println(input);
            input = sc.next();
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        String input = sc.next();

        while(!(input.equals("-"))){
            int time = sc.nextInt();
            for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            }
            System.out.println(input);
            input = sc.next();
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input = sc.next(); input sc.next() sc.next sc while(!(input.equals("-"))){
            int time = sc.nextInt();
            for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            }
            System.out.println(input);
            input = sc.next();
        } !(input.equals("-")) (input.equals("-")) input.equals input "-" {
            int time = sc.nextInt();
            for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            }
            System.out.println(input);
            input = sc.next();
        } int time = sc.nextInt(); time sc.nextInt() sc.nextInt sc for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            } int i = 0; int i = 0; i 0 i < time i time i++ i++ i {
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            } {
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            } int place = sc.nextInt(); place sc.nextInt() sc.nextInt sc input = input.substring(place) + input.substring(0, place) input input.substring(place) + input.substring(0, place) input.substring(place) input.substring input place input.substring(0, place) input.substring input 0 place System.out.println(input) System.out.println System.out System System.out input input = sc.next() input sc.next() sc.next sc sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String input = sc.next();

        while(!(input.equals("-"))){
            int time = sc.nextInt();
            for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            }
            System.out.println(input);
            input = sc.next();
        }
        sc.close();
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String input = sc.next();

        while(!(input.equals("-"))){
            int time = sc.nextInt();
            for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            }
            System.out.println(input);
            input = sc.next();
        }
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String input = sc.next();

        while(!(input.equals("-"))){
            int time = sc.nextInt();
            for(int i = 0; i < time; i++){
                int place = sc.nextInt();
                input = input.substring(place) + input.substring(0, place);

            }
            System.out.println(input);
            input = sc.next();
        }
        sc.close();
    }
}
