import java.util.Scanner;

public class Main {

    public static void main(String[] args)throws Exception {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        while (!(line.equals("-"))) {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        }
        sc.close();

    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args)throws Exception {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        while (!(line.equals("-"))) {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        }
        sc.close();

    }

} Main public static void main(String[] args)throws Exception {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        while (!(line.equals("-"))) {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        }
        sc.close();

    } main {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        while (!(line.equals("-"))) {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        }
        sc.close();

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc while (!(line.equals("-"))) {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        } !(line.equals("-")) (line.equals("-")) line.equals line "-" {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        } String num = sc.nextLine(); num sc.nextLine() sc.nextLine sc int n = Integer.parseInt(num); n Integer.parseInt(num) Integer.parseInt Integer num for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            } {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            } int count = Integer.parseInt(sc.nextLine()); count Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc line = line.substring(count) + line.substring(0, count) line line.substring(count) + line.substring(0, count) line.substring(count) line.substring line count line.substring(0, count) line.substring line 0 count System.out.println(line) System.out.println System.out System System.out line line = sc.nextLine() line sc.nextLine() sc.nextLine sc sc.close() sc.close sc String[] args args public class Main {

    public static void main(String[] args)throws Exception {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        while (!(line.equals("-"))) {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        }
        sc.close();

    }

} public class Main {

    public static void main(String[] args)throws Exception {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        while (!(line.equals("-"))) {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        }
        sc.close();

    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args)throws Exception {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        while (!(line.equals("-"))) {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        }
        sc.close();

    }

}