import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String mae = "";
        String usiro = "";
        while(!word.equals("-")){
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        }
        sc.close();
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String mae = "";
        String usiro = "";
        while(!word.equals("-")){
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        }
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String mae = "";
        String usiro = "";
        while(!word.equals("-")){
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String mae = "";
        String usiro = "";
        while(!word.equals("-")){
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String word = sc.next(); word sc.next() sc.next sc String mae = ""; mae "" String usiro = ""; usiro "" while(!word.equals("-")){
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        } !word.equals("-") word.equals("-") word.equals word "-" {
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        } int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            } {
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            } int a  = sc.nextInt(); a sc.nextInt() sc.nextInt sc usiro = word.substring(a) usiro word.substring(a) word.substring word a mae = word.substring(0,a) mae word.substring(0,a) word.substring word 0 a word = usiro + mae word usiro + mae usiro mae System.out.println(word) System.out.println System.out System System.out word word = sc.next() word sc.next() sc.next sc sc.close() sc.close sc String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String mae = "";
        String usiro = "";
        while(!word.equals("-")){
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        }
        sc.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String mae = "";
        String usiro = "";
        while(!word.equals("-")){
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        }
        sc.close();
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String mae = "";
        String usiro = "";
        while(!word.equals("-")){
            int n = sc.nextInt();
            for(int i=0;i<n;i++){
                int a  = sc.nextInt();
                usiro = word.substring(a);
                mae = word.substring(0,a);
                word = usiro + mae;
            }
            System.out.println(word);
            word = sc.next();
        }
        sc.close();
    }
}
