import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true){
        String a = sc.next();
        if(a.equals("-")){
                break;
            }
        int b = sc.nextInt();
        int i = 0;
        String a1, a2;
        
        
        for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        }
        
        System.out.println(a);
    }
        sc.close();
    }

} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true){
        String a = sc.next();
        if(a.equals("-")){
                break;
            }
        int b = sc.nextInt();
        int i = 0;
        String a1, a2;
        
        
        for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        }
        
        System.out.println(a);
    }
        sc.close();
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true){
        String a = sc.next();
        if(a.equals("-")){
                break;
            }
        int b = sc.nextInt();
        int i = 0;
        String a1, a2;
        
        
        for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        }
        
        System.out.println(a);
    }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        while(true){
        String a = sc.next();
        if(a.equals("-")){
                break;
            }
        int b = sc.nextInt();
        int i = 0;
        String a1, a2;
        
        
        for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        }
        
        System.out.println(a);
    }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
        String a = sc.next();
        if(a.equals("-")){
                break;
            }
        int b = sc.nextInt();
        int i = 0;
        String a1, a2;
        
        
        for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        }
        
        System.out.println(a);
    } true {
        String a = sc.next();
        if(a.equals("-")){
                break;
            }
        int b = sc.nextInt();
        int i = 0;
        String a1, a2;
        
        
        for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        }
        
        System.out.println(a);
    } String a = sc.next(); a sc.next() sc.next sc if(a.equals("-")){
                break;
            } a.equals("-") a.equals a "-" {
                break;
            } break; int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int i = 0; i 0 String a1 a1 a2; a2 for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        } i = 0; i = 0 i 0 i < b i b i++ i++ i {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        } {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        } int c= sc.nextInt(); c sc.nextInt() sc.nextInt sc a1=a.substring(0,c) a1 a.substring(0,c) a.substring a 0 c a2=a.substring(c) a2 a.substring(c) a.substring a c a=a2+a1 a a2+a1 a2 a1 System.out.println(a) System.out.println System.out System System.out a sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true){
        String a = sc.next();
        if(a.equals("-")){
                break;
            }
        int b = sc.nextInt();
        int i = 0;
        String a1, a2;
        
        
        for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        }
        
        System.out.println(a);
    }
        sc.close();
    }

} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true){
        String a = sc.next();
        if(a.equals("-")){
                break;
            }
        int b = sc.nextInt();
        int i = 0;
        String a1, a2;
        
        
        for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        }
        
        System.out.println(a);
    }
        sc.close();
    }

} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true){
        String a = sc.next();
        if(a.equals("-")){
                break;
            }
        int b = sc.nextInt();
        int i = 0;
        String a1, a2;
        
        
        for (i = 0; i < b; i++) {
            int c= sc.nextInt();

            
            
            a1=a.substring(0,c);
            a2=a.substring(c);
             a=a2+a1;
        }
        
        System.out.println(a);
    }
        sc.close();
    }

}
