import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        }
    }
} 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 str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            String str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        } true {
            String str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        } String str = sc.next(); str sc.next() sc.next sc if(str.equals("-")) break; str.equals("-") str.equals str "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] array = new int[m]; array new int[m] m String result = str; result str for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            } {
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            } int shuffleNum = sc.nextInt(); shuffleNum sc.nextInt() sc.nextInt sc result = result.substring(shuffleNum) + result.substring(0, shuffleNum) result result.substring(shuffleNum) + result.substring(0, shuffleNum) result.substring(shuffleNum) result.substring result shuffleNum result.substring(0, shuffleNum) result.substring result 0 shuffleNum System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        }
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")) break;
            int m = sc.nextInt();
            int[] array = new int[m];
            String result = str;
            for(int i = 0; i < m; i++){
                int shuffleNum = sc.nextInt();
                result = result.substring(shuffleNum) + result.substring(0, shuffleNum);
            }
            System.out.println(result);
        }
    }
}
