import java.util.Scanner;

public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while(!s.equals("-")){
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
}
 import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while(!s.equals("-")){
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
} Main public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while(!s.equals("-")){
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    } main {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while(!s.equals("-")){
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String s = scanner.next(); s scanner.next() scanner.next scanner while(!s.equals("-")){
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        } !s.equals("-") s.equals("-") s.equals s "-" {
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        } int m = scanner.nextInt(); m scanner.nextInt() scanner.nextInt scanner for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            } {
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            } int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int l = s.length(); l s.length() s.length s String tmp1 = s.substring(0, n); tmp1 s.substring(0, n) s.substring s 0 n String tmp2 = s.substring(n, l); tmp2 s.substring(n, l) s.substring s n l s = tmp2 + tmp1 s tmp2 + tmp1 tmp2 tmp1 System.out.println(s) System.out.println System.out System System.out s s = scanner.next() s scanner.next() scanner.next scanner String[] args args public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while(!s.equals("-")){
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
} public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while(!s.equals("-")){
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while(!s.equals("-")){
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
}

