import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str,tmp;
        int j,strnum;
        str = sc.next();
        while(!str.equals("-")){
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            }
            System.out.println(str);
            str = sc.next();
        }
    }
} import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str,tmp;
        int j,strnum;
        str = sc.next();
        while(!str.equals("-")){
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            }
            System.out.println(str);
            str = sc.next();
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str,tmp;
        int j,strnum;
        str = sc.next();
        while(!str.equals("-")){
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            }
            System.out.println(str);
            str = sc.next();
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String str,tmp;
        int j,strnum;
        str = sc.next();
        while(!str.equals("-")){
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            }
            System.out.println(str);
            str = sc.next();
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str str tmp; tmp int j j strnum; strnum str = sc.next() str sc.next() sc.next sc while(!str.equals("-")){
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            }
            System.out.println(str);
            str = sc.next();
        } !str.equals("-") str.equals("-") str.equals str "-" {
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            }
            System.out.println(str);
            str = sc.next();
        } int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            } {
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            } int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc tmp = str.substring(h) tmp str.substring(h) str.substring str h strnum = str.length() strnum str.length() str.length str str = tmp + str str tmp + str tmp str str = str.substring(0,strnum) str str.substring(0,strnum) str.substring str 0 strnum System.out.println(str) System.out.println System.out System System.out str str = sc.next() str sc.next() sc.next sc String[] args args
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str,tmp;
        int j,strnum;
        str = sc.next();
        while(!str.equals("-")){
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            }
            System.out.println(str);
            str = sc.next();
        }
    }
}
