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


/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz