import java.util.HashMap;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.Collections;
import java.math.BigDecimal;
import java.util.LinkedList;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        LinkedList<Character> list;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("-")) break;
            int n = sc.nextInt();
            list = new LinkedList<>();
            
            for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            }
            
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            }
            System.out.println(sb);
        }
    }
} import java.util.HashMap; HashMap java.util import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util import java.util.regex.Pattern; Pattern java.util.regex import java.util.Collections; Collections java.util import java.math.BigDecimal; BigDecimal java.math import java.util.LinkedList; LinkedList java.util public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        LinkedList<Character> list;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("-")) break;
            int n = sc.nextInt();
            list = new LinkedList<>();
            
            for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            }
            
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            }
            System.out.println(sb);
        }
    }
} Main public static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) throws Exception {
        LinkedList<Character> list;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("-")) break;
            int n = sc.nextInt();
            list = new LinkedList<>();
            
            for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            }
            
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            }
            System.out.println(sb);
        }
    } main {
        LinkedList<Character> list;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("-")) break;
            int n = sc.nextInt();
            list = new LinkedList<>();
            
            for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            }
            
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            }
            System.out.println(sb);
        }
    } LinkedList<Character> list; list while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("-")) break;
            int n = sc.nextInt();
            list = new LinkedList<>();
            
            for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            }
            
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            }
            System.out.println(sb);
        } sc.hasNext() sc.hasNext sc {
            String s = sc.next();
            if (s.equals("-")) break;
            int n = sc.nextInt();
            list = new LinkedList<>();
            
            for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            }
            
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            }
            System.out.println(sb);
        } String s = sc.next(); s sc.next() sc.next sc if (s.equals("-")) break; s.equals("-") s.equals s "-" break; int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc list = new LinkedList<>() list new LinkedList<>() for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
                list.addLast(s.charAt(i));
            } {
                list.addLast(s.charAt(i));
            } list.addLast(s.charAt(i)) list.addLast list s.charAt(i) s.charAt s i for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            } {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            } int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                } int j = 0; int j = 0; j 0 j < m j m j++ j++ j {
                    list.addLast(list.pollFirst());
                } {
                    list.addLast(list.pollFirst());
                } list.addLast(list.pollFirst()) list.addLast list list.pollFirst() list.pollFirst list StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            } int i = 0; int i = 0; i 0 i < list.size() i list.size() list.size list i++ i++ i {
                sb.append(list.get(i));
            } {
                sb.append(list.get(i));
            } sb.append(list.get(i)) sb.append sb list.get(i) list.get list i System.out.println(sb) System.out.println System.out System System.out sb String[] args args public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        LinkedList<Character> list;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("-")) break;
            int n = sc.nextInt();
            list = new LinkedList<>();
            
            for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            }
            
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            }
            System.out.println(sb);
        }
    }
} public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        LinkedList<Character> list;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("-")) break;
            int n = sc.nextInt();
            list = new LinkedList<>();
            
            for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            }
            
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            }
            System.out.println(sb);
        }
    }
} Main
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.Collections;
import java.math.BigDecimal;
import java.util.LinkedList;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        LinkedList<Character> list;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("-")) break;
            int n = sc.nextInt();
            list = new LinkedList<>();
            
            for (int i = 0; i < s.length(); i++) {
                list.addLast(s.charAt(i));
            }
            
            for (int i = 0; i < n; i++) {
                int m = sc.nextInt();
                for (int j = 0; j < m; j++) {
                    list.addLast(list.pollFirst());
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                sb.append(list.get(i));
            }
            System.out.println(sb);
        }
    }
}