import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int i;
        Deck d=new Deck();
        while(!(s=sc.next()).equals("-")){
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        }
    }
}

class Deck{
    private String str;
    Deck(){
    }
    void setDeck(String s){
        this.str=s;
    }
    void shuffle(int h){
        this.str=this.str.substring(h,this.str.length())+this.str.substring(0,h);
    }
    void printDeck(){
        System.out.println(this.str);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int i;
        Deck d=new Deck();
        while(!(s=sc.next()).equals("-")){
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        }
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int i;
        Deck d=new Deck();
        while(!(s=sc.next()).equals("-")){
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        }
    } main {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int i;
        Deck d=new Deck();
        while(!(s=sc.next()).equals("-")){
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        }
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String s; s int m; m int i; i Deck d=new Deck(); d new Deck() while(!(s=sc.next()).equals("-")){
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        } !(s=sc.next()).equals("-") (s=sc.next()).equals("-") (s=sc.next()).equals (s=sc.next()) s sc.next() sc.next sc "-" {
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        } d.setDeck(s) d.setDeck d s m=sc.nextInt() m sc.nextInt() sc.nextInt sc for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            } i=0; i=0 i 0 i<m i m i++ i++ i {
                d.shuffle(sc.nextInt());
            } {
                d.shuffle(sc.nextInt());
            } d.shuffle(sc.nextInt()) d.shuffle d sc.nextInt() sc.nextInt sc d.printDeck() d.printDeck d String[] args args class Deck{
    private String str;
    Deck(){
    }
    void setDeck(String s){
        this.str=s;
    }
    void shuffle(int h){
        this.str=this.str.substring(h,this.str.length())+this.str.substring(0,h);
    }
    void printDeck(){
        System.out.println(this.str);
    }
} Deck private String str; str Deck(){
    } Deck {
    } void setDeck(String s){
        this.str=s;
    } setDeck {
        this.str=s;
    } this.str=s this.str this this.str s String s s void shuffle(int h){
        this.str=this.str.substring(h,this.str.length())+this.str.substring(0,h);
    } shuffle {
        this.str=this.str.substring(h,this.str.length())+this.str.substring(0,h);
    } this.str=this.str.substring(h,this.str.length())+this.str.substring(0,h) this.str this this.str this.str.substring(h,this.str.length())+this.str.substring(0,h) this.str.substring(h,this.str.length()) this.str.substring this.str this this.str h this.str.length() this.str.length this.str this this.str this.str.substring(0,h) this.str.substring this.str this this.str 0 h int h h void printDeck(){
        System.out.println(this.str);
    } printDeck {
        System.out.println(this.str);
    } System.out.println(this.str) System.out.println System.out System System.out this.str this this.str public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int i;
        Deck d=new Deck();
        while(!(s=sc.next()).equals("-")){
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int i;
        Deck d=new Deck();
        while(!(s=sc.next()).equals("-")){
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int i;
        Deck d=new Deck();
        while(!(s=sc.next()).equals("-")){
            d.setDeck(s);
            m=sc.nextInt();
            for(i=0;i<m;i++){
                d.shuffle(sc.nextInt());
            }
            d.printDeck();
        }
    }
}

class Deck{
    private String str;
    Deck(){
    }
    void setDeck(String s){
        this.str=s;
    }
    void shuffle(int h){
        this.str=this.str.substring(h,this.str.length())+this.str.substring(0,h);
    }
    void printDeck(){
        System.out.println(this.str);
    }
}
