import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
        while(true){
    		String s=in.next();
    		if(s.equals("-"))break;
            int k=in.nextInt();
    		StringBuilder sb = new StringBuilder(s);
            for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            }
            System.out.println(sb);
        }
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
        while(true){
    		String s=in.next();
    		if(s.equals("-"))break;
            int k=in.nextInt();
    		StringBuilder sb = new StringBuilder(s);
            for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            }
            System.out.println(sb);
        }
	}
} Main public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
        while(true){
    		String s=in.next();
    		if(s.equals("-"))break;
            int k=in.nextInt();
    		StringBuilder sb = new StringBuilder(s);
            for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            }
            System.out.println(sb);
        }
	} main {
		Scanner in = new Scanner(System.in);
        while(true){
    		String s=in.next();
    		if(s.equals("-"))break;
            int k=in.nextInt();
    		StringBuilder sb = new StringBuilder(s);
            for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            }
            System.out.println(sb);
        }
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) while(true){
    		String s=in.next();
    		if(s.equals("-"))break;
            int k=in.nextInt();
    		StringBuilder sb = new StringBuilder(s);
            for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            }
            System.out.println(sb);
        } true {
    		String s=in.next();
    		if(s.equals("-"))break;
            int k=in.nextInt();
    		StringBuilder sb = new StringBuilder(s);
            for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            }
            System.out.println(sb);
        } String s=in.next(); s in.next() in.next in if(s.equals("-"))break; s.equals("-") s.equals s "-" break; int k=in.nextInt(); k in.nextInt() in.nextInt in StringBuilder sb = new StringBuilder(s); sb new StringBuilder(s) for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            } int i=0; int i=0; i 0 i<k i k i++ i++ i {
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            } {
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            } int h=in.nextInt(); h in.nextInt() in.nextInt in sb.append(sb.substring(0,h)) sb.append sb sb.substring(0,h) sb.substring sb 0 h sb.delete(0, h) sb.delete sb 0 h System.out.println(sb) System.out.println System.out System System.out sb String[] args args
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
        while(true){
    		String s=in.next();
    		if(s.equals("-"))break;
            int k=in.nextInt();
    		StringBuilder sb = new StringBuilder(s);
            for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            }
            System.out.println(sb);
        }
	}
}