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