import java.util.Scanner;

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

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