import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
    while(kbd.hasNext()){
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    }
    }
  
    static void solve(String cards){
    int m = kbd.nextInt();
    while(m > 0){
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    }
    System.out.println(cards);
    }
} import java.util.*; util.* java public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
    while(kbd.hasNext()){
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    }
    }
  
    static void solve(String cards){
    int m = kbd.nextInt();
    while(m > 0){
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    }
    System.out.println(cards);
    }
} Main static Scanner kbd = new Scanner(System.in); kbd new Scanner(System.in) public static void main(String[] args){
    while(kbd.hasNext()){
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    }
    } main {
    while(kbd.hasNext()){
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    }
    } while(kbd.hasNext()){
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    } kbd.hasNext() kbd.hasNext kbd {
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    } String cards = kbd.next(); cards kbd.next() kbd.next kbd if(!cards.equals("-")){
        solve(cards);
        } !cards.equals("-") cards.equals("-") cards.equals cards "-" {
        solve(cards);
        } solve(cards) solve cards String[] args args static void solve(String cards){
    int m = kbd.nextInt();
    while(m > 0){
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    }
    System.out.println(cards);
    } solve {
    int m = kbd.nextInt();
    while(m > 0){
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    }
    System.out.println(cards);
    } int m = kbd.nextInt(); m kbd.nextInt() kbd.nextInt kbd while(m > 0){
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    } m > 0 m 0 {
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    } int a = kbd.nextInt(); a kbd.nextInt() kbd.nextInt kbd String fore = cards.substring(0, a); fore cards.substring(0, a) cards.substring cards 0 a String back = cards.substring(a, cards.length()); back cards.substring(a, cards.length()) cards.substring cards a cards.length() cards.length cards cards = back+fore cards back+fore back fore m-- m System.out.println(cards) System.out.println System.out System System.out cards String cards cards public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
    while(kbd.hasNext()){
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    }
    }
  
    static void solve(String cards){
    int m = kbd.nextInt();
    while(m > 0){
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    }
    System.out.println(cards);
    }
} public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
    while(kbd.hasNext()){
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    }
    }
  
    static void solve(String cards){
    int m = kbd.nextInt();
    while(m > 0){
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    }
    System.out.println(cards);
    }
} Main
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
    while(kbd.hasNext()){
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    }
    }
  
    static void solve(String cards){
    int m = kbd.nextInt();
    while(m > 0){
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    }
    System.out.println(cards);
    }
}
