import java.util.Scanner;

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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i;
        String str;
        while(true){
            str = sc.next();
            if(str.equals("-")){
                break;
            }
            String str1;
            String str2;
            int m;
            m = sc.nextInt();
            int h;
            for(i=0;i<m;i++){
                h = sc.nextInt();
                str1 = str.substring(0,h);
                str2 = str.substring(h);
                str = str2 + str1;
            }
            System.out.println(str);
        }
        sc.close();
    }
}
