import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int i=0;
        while(!(a.equals("-"))){
            int num = sc.nextInt();
            for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            }
            System.out.println(a);
            a = sc.next();
        }
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int i=0;
        while(!(a.equals("-"))){
            int num = sc.nextInt();
            for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            }
            System.out.println(a);
            a = sc.next();
        }
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int i=0;
        while(!(a.equals("-"))){
            int num = sc.nextInt();
            for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            }
            System.out.println(a);
            a = sc.next();
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int i=0;
        while(!(a.equals("-"))){
            int num = sc.nextInt();
            for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            }
            System.out.println(a);
            a = sc.next();
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.next(); a sc.next() sc.next sc int i=0; i 0 while(!(a.equals("-"))){
            int num = sc.nextInt();
            for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            }
            System.out.println(a);
            a = sc.next();
        } !(a.equals("-")) (a.equals("-")) a.equals a "-" {
            int num = sc.nextInt();
            for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            }
            System.out.println(a);
            a = sc.next();
        } int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            } i=0; i=0 i 0 i<num i num i++ i++ i {
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            } {
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            } int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String l = a.substring(0,n); l a.substring(0,n) a.substring a 0 n String r = a.substring(n); r a.substring(n) a.substring a n a = r + l a r + l r l System.out.println(a) System.out.println System.out System System.out a a = sc.next() a 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 a = sc.next();
        int i=0;
        while(!(a.equals("-"))){
            int num = sc.nextInt();
            for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            }
            System.out.println(a);
            a = sc.next();
        }
        sc.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int i=0;
        while(!(a.equals("-"))){
            int num = sc.nextInt();
            for(i=0;i<num;i++){
                int n = sc.nextInt();
                String l = a.substring(0,n);
                String r = a.substring(n);
                a = r + l;
            }
            System.out.println(a);
            a = sc.next();
        }
        sc.close();
    }
} Main
import java.util.Scanner;

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