import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int times, time_count;
        while(sc.hasNext()){
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        }
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int times, time_count;
        while(sc.hasNext()){
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int times, time_count;
        while(sc.hasNext()){
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        }
    } main {
        Scanner sc = new Scanner (System.in);
        int times, time_count;
        while(sc.hasNext()){
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        }
    } Scanner sc = new Scanner (System.in); sc new Scanner (System.in) int times times time_count; time_count while(sc.hasNext()){
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        } sc.hasNext() sc.hasNext sc {
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        } String word = sc.next(); word sc.next() sc.next sc if(word.equals("-")) break; word.equals("-") word.equals word "-" break; times = sc.nextInt() times sc.nextInt() sc.nextInt sc for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            } int i = 0; int i = 0; i 0 i < times i times i++ i++ i {
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            } {
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            } time_count = sc.nextInt() time_count sc.nextInt() sc.nextInt sc word = word.substring(time_count, word.length()) + word.substring(0, time_count) word word.substring(time_count, word.length()) + word.substring(0, time_count) word.substring(time_count, word.length()) word.substring word time_count word.length() word.length word word.substring(0, time_count) word.substring word 0 time_count System.out.println(word) System.out.println System.out System System.out word String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int times, time_count;
        while(sc.hasNext()){
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int times, time_count;
        while(sc.hasNext()){
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        }
    }
} Main
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int times, time_count;
        while(sc.hasNext()){
            String word = sc.next();
            if(word.equals("-")) break;
               times = sc.nextInt();
            for(int i = 0; i < times; i++){
                time_count = sc.nextInt();
                word = word.substring(time_count, word.length()) + word.substring(0, time_count);
            }
            System.out.println(word);
        }
    }
}
