import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.nextLine();
            if ("-".equals(str)) {
                break;
            }
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int bi = sum % str.length();
            int ei = bi + str.length();
            String res = (str + str).substring(bi, ei);
            System.out.println(res);
            sc.nextLine();
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.nextLine();
            if ("-".equals(str)) {
                break;
            }
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int bi = sum % str.length();
            int ei = bi + str.length();
            String res = (str + str).substring(bi, ei);
            System.out.println(res);
            sc.nextLine();
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.nextLine();
            if ("-".equals(str)) {
                break;
            }
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int bi = sum % str.length();
            int ei = bi + str.length();
            String res = (str + str).substring(bi, ei);
            System.out.println(res);
            sc.nextLine();
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.nextLine();
            if ("-".equals(str)) {
                break;
            }
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int bi = sum % str.length();
            int ei = bi + str.length();
            String res = (str + str).substring(bi, ei);
            System.out.println(res);
            sc.nextLine();
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            String str = sc.nextLine();
            if ("-".equals(str)) {
                break;
            }
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int bi = sum % str.length();
            int ei = bi + str.length();
            String res = (str + str).substring(bi, ei);
            System.out.println(res);
            sc.nextLine();
        } true {
            String str = sc.nextLine();
            if ("-".equals(str)) {
                break;
            }
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int bi = sum % str.length();
            int ei = bi + str.length();
            String res = (str + str).substring(bi, ei);
            System.out.println(res);
            sc.nextLine();
        } String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc if ("-".equals(str)) {
                break;
            } "-".equals(str) "-".equals "-" str {
                break;
            } break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int sum = 0; sum 0 for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                sum += sc.nextInt();
            } {
                sum += sc.nextInt();
            } sum += sc.nextInt() sum sc.nextInt() sc.nextInt sc int bi = sum % str.length(); bi sum % str.length() sum str.length() str.length str int ei = bi + str.length(); ei bi + str.length() bi str.length() str.length str String res = (str + str).substring(bi, ei); res (str + str).substring(bi, ei) (str + str).substring (str + str) str str bi ei System.out.println(res) System.out.println System.out System System.out res sc.nextLine() sc.nextLine sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.nextLine();
            if ("-".equals(str)) {
                break;
            }
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int bi = sum % str.length();
            int ei = bi + str.length();
            String res = (str + str).substring(bi, ei);
            System.out.println(res);
            sc.nextLine();
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.nextLine();
            if ("-".equals(str)) {
                break;
            }
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int bi = sum % str.length();
            int ei = bi + str.length();
            String res = (str + str).substring(bi, ei);
            System.out.println(res);
            sc.nextLine();
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.nextLine();
            if ("-".equals(str)) {
                break;
            }
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int bi = sum % str.length();
            int ei = bi + str.length();
            String res = (str + str).substring(bi, ei);
            System.out.println(res);
            sc.nextLine();
        }
    }
}