
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        while (sc.hasNext()){
            String alf = sc.next();
            if (alf.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            }
            System.out.println(alf);

        }
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        while (sc.hasNext()){
            String alf = sc.next();
            if (alf.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            }
            System.out.println(alf);

        }
    }
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        while (sc.hasNext()){
            String alf = sc.next();
            if (alf.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            }
            System.out.println(alf);

        }
    } main {
        while (sc.hasNext()){
            String alf = sc.next();
            if (alf.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            }
            System.out.println(alf);

        }
    } while (sc.hasNext()){
            String alf = sc.next();
            if (alf.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            }
            System.out.println(alf);

        } sc.hasNext() sc.hasNext sc {
            String alf = sc.next();
            if (alf.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            }
            System.out.println(alf);

        } String alf = sc.next(); alf sc.next() sc.next sc if (alf.equals("-"))
                break; alf.equals("-") alf.equals alf "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            } {
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            } int subNum = sc.nextInt(); subNum sc.nextInt() sc.nextInt sc String tmpSub = alf.substring(0,subNum); tmpSub alf.substring(0,subNum) alf.substring alf 0 subNum String tmp = alf.substring(subNum); tmp alf.substring(subNum) alf.substring alf subNum alf = tmp + tmpSub alf tmp + tmpSub tmp tmpSub System.out.println(alf) System.out.println System.out System System.out alf String[] args args public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        while (sc.hasNext()){
            String alf = sc.next();
            if (alf.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            }
            System.out.println(alf);

        }
    }
} public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        while (sc.hasNext()){
            String alf = sc.next();
            if (alf.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            }
            System.out.println(alf);

        }
    }
} Main

import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        while (sc.hasNext()){
            String alf = sc.next();
            if (alf.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++){
                int subNum = sc.nextInt();
                String tmpSub = alf.substring(0,subNum);
                String tmp = alf.substring(subNum);
                alf = tmp + tmpSub;
            }
            System.out.println(alf);

        }
    }
}

