import java.util.Scanner;

public class Main {

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

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int i,n,h,len;
        String s,sa,sb;
        while(true) {
        	s=scan.next();
        	if(s.equals("-")) {
        		break;
        	}
        	len=s.length();
        	n=scan.nextInt();
        	for(i=0;i<n;i++) {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	}
        	System.out.println(s);
        }
    }
} Main public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int i,n,h,len;
        String s,sa,sb;
        while(true) {
        	s=scan.next();
        	if(s.equals("-")) {
        		break;
        	}
        	len=s.length();
        	n=scan.nextInt();
        	for(i=0;i<n;i++) {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	}
        	System.out.println(s);
        }
    } main {
        Scanner scan=new Scanner(System.in);
        int i,n,h,len;
        String s,sa,sb;
        while(true) {
        	s=scan.next();
        	if(s.equals("-")) {
        		break;
        	}
        	len=s.length();
        	n=scan.nextInt();
        	for(i=0;i<n;i++) {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	}
        	System.out.println(s);
        }
    } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int i i n n h h len; len String s s sa sa sb; sb while(true) {
        	s=scan.next();
        	if(s.equals("-")) {
        		break;
        	}
        	len=s.length();
        	n=scan.nextInt();
        	for(i=0;i<n;i++) {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	}
        	System.out.println(s);
        } true {
        	s=scan.next();
        	if(s.equals("-")) {
        		break;
        	}
        	len=s.length();
        	n=scan.nextInt();
        	for(i=0;i<n;i++) {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	}
        	System.out.println(s);
        } s=scan.next() s scan.next() scan.next scan if(s.equals("-")) {
        		break;
        	} s.equals("-") s.equals s "-" {
        		break;
        	} break; len=s.length() len s.length() s.length s n=scan.nextInt() n scan.nextInt() scan.nextInt scan for(i=0;i<n;i++) {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	} i=0; i=0 i 0 i<n i n i++ i++ i {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	} {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	} h=scan.nextInt() h scan.nextInt() scan.nextInt scan sa=s.substring(0,h) sa s.substring(0,h) s.substring s 0 h sb=s.substring(h) sb s.substring(h) s.substring s h s=sb+sa s sb+sa sb sa System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int i,n,h,len;
        String s,sa,sb;
        while(true) {
        	s=scan.next();
        	if(s.equals("-")) {
        		break;
        	}
        	len=s.length();
        	n=scan.nextInt();
        	for(i=0;i<n;i++) {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	}
        	System.out.println(s);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int i,n,h,len;
        String s,sa,sb;
        while(true) {
        	s=scan.next();
        	if(s.equals("-")) {
        		break;
        	}
        	len=s.length();
        	n=scan.nextInt();
        	for(i=0;i<n;i++) {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	}
        	System.out.println(s);
        }
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int i,n,h,len;
        String s,sa,sb;
        while(true) {
        	s=scan.next();
        	if(s.equals("-")) {
        		break;
        	}
        	len=s.length();
        	n=scan.nextInt();
        	for(i=0;i<n;i++) {
        		h=scan.nextInt();
        		sa=s.substring(0,h);
        		sb=s.substring(h);
        		s=sb+sa;
        	}
        	System.out.println(s);
        }
    }
}
