import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        Queue<Character> q = new ArrayDeque<>();

        while (true) {
            s = sc.next();
            if (s.equals("-"))
                break;
            
            for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            }

            int m;
            m = sc.nextInt();

            int[] h = new int[m];
            int sum = 0;

            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            }

            for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            }
            for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            }
            System.out.println();
        }

        sc.close();
    }
} import java.util.Scanner; Scanner java.util import java.util.Queue; Queue java.util import java.util.ArrayDeque; ArrayDeque java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        Queue<Character> q = new ArrayDeque<>();

        while (true) {
            s = sc.next();
            if (s.equals("-"))
                break;
            
            for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            }

            int m;
            m = sc.nextInt();

            int[] h = new int[m];
            int sum = 0;

            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            }

            for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            }
            for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            }
            System.out.println();
        }

        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        Queue<Character> q = new ArrayDeque<>();

        while (true) {
            s = sc.next();
            if (s.equals("-"))
                break;
            
            for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            }

            int m;
            m = sc.nextInt();

            int[] h = new int[m];
            int sum = 0;

            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            }

            for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            }
            for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            }
            System.out.println();
        }

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        String s;
        Queue<Character> q = new ArrayDeque<>();

        while (true) {
            s = sc.next();
            if (s.equals("-"))
                break;
            
            for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            }

            int m;
            m = sc.nextInt();

            int[] h = new int[m];
            int sum = 0;

            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            }

            for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            }
            for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            }
            System.out.println();
        }

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s; s Queue<Character> q = new ArrayDeque<>(); q new ArrayDeque<>() while (true) {
            s = sc.next();
            if (s.equals("-"))
                break;
            
            for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            }

            int m;
            m = sc.nextInt();

            int[] h = new int[m];
            int sum = 0;

            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            }

            for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            }
            for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            }
            System.out.println();
        } true {
            s = sc.next();
            if (s.equals("-"))
                break;
            
            for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            }

            int m;
            m = sc.nextInt();

            int[] h = new int[m];
            int sum = 0;

            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            }

            for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            }
            for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            }
            System.out.println();
        } s = sc.next() s sc.next() sc.next sc if (s.equals("-"))
                break; s.equals("-") s.equals s "-" break; for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
                q.add(s.charAt(i));
            } {
                q.add(s.charAt(i));
            } q.add(s.charAt(i)) q.add q s.charAt(i) s.charAt s i int m; m m = sc.nextInt() m sc.nextInt() sc.nextInt sc int[] h = new int[m]; h new int[m] m int sum = 0; sum 0 for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                h[i] = sc.nextInt();
                sum += h[i];
            } {
                h[i] = sc.nextInt();
                sum += h[i];
            } h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc sum += h[i] sum h[i] h i for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            } int i = 0; int i = 0; i 0 i < sum i sum i++ i++ i {
                q.add(q.poll());
            } {
                q.add(q.poll());
            } q.add(q.poll()) q.add q q.poll() q.poll q for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
                System.out.print(q.poll());
            } {
                System.out.print(q.poll());
            } System.out.print(q.poll()) System.out.print System.out System System.out q.poll() q.poll q System.out.println() System.out.println System.out System System.out sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        Queue<Character> q = new ArrayDeque<>();

        while (true) {
            s = sc.next();
            if (s.equals("-"))
                break;
            
            for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            }

            int m;
            m = sc.nextInt();

            int[] h = new int[m];
            int sum = 0;

            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            }

            for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            }
            for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            }
            System.out.println();
        }

        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        Queue<Character> q = new ArrayDeque<>();

        while (true) {
            s = sc.next();
            if (s.equals("-"))
                break;
            
            for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            }

            int m;
            m = sc.nextInt();

            int[] h = new int[m];
            int sum = 0;

            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            }

            for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            }
            for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            }
            System.out.println();
        }

        sc.close();
    }
} Main
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        Queue<Character> q = new ArrayDeque<>();

        while (true) {
            s = sc.next();
            if (s.equals("-"))
                break;
            
            for (int i = 0; i < s.length(); i++) {
                q.add(s.charAt(i));
            }

            int m;
            m = sc.nextInt();

            int[] h = new int[m];
            int sum = 0;

            for (int i = 0; i < m; i++) {
                h[i] = sc.nextInt();
                sum += h[i];
            }

            for (int i = 0; i < sum; i++) {
                q.add(q.poll());
            }
            for (int i = 0; i < s.length(); i++) {
                System.out.print(q.poll());
            }
            System.out.println();
        }

        sc.close();
    }
}
