import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        for( ; ; ){
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        }
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        for( ; ; ){
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        }
        sc.close();
    }
} Main public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        for( ; ; ){
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        for( ; ; ){
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) for( ; ; ){
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        } ; {
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        } {
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        } String x = sc.next(); x sc.next() sc.next sc if(x.equals("-")){
                 break;
            } x.equals("-") x.equals x "-" {
                 break;
            } break; for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            } int n = sc.nextInt() ; int n = sc.nextInt() ; n sc.nextInt() sc.nextInt sc n > 0 n 0 n-- n-- n {
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            } {
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            } int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc x = x.substring(a) + x.substring(0,a) x x.substring(a) + x.substring(0,a) x.substring(a) x.substring x a x.substring(0,a) x.substring x 0 a System.out.println(x) System.out.println System.out System System.out x sc.close() sc.close sc String[] arg arg public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        for( ; ; ){
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        }
        sc.close();
    }
} public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        for( ; ; ){
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        }
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        for( ; ; ){
            String x = sc.next();
            if(x.equals("-")){
                 break;
            }
            for(int n = sc.nextInt() ; n > 0; n--){
                int a = sc.nextInt();
                x = x.substring(a) + x.substring(0,a);
            }
            System.out.println(x);
        }
        sc.close();
    }
}
