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

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Queue<String> queue = new ArrayDeque<>();
        int i,k;

        while(true)
        {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        }
        sc.close();
    }
} import java.util.Scanner; Scanner java.util import java.util.ArrayDeque; ArrayDeque java.util import java.util.Queue; Queue java.util public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Queue<String> queue = new ArrayDeque<>();
        int i,k;

        while(true)
        {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        }
        sc.close();
    }
} Main public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Queue<String> queue = new ArrayDeque<>();
        int i,k;

        while(true)
        {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        Queue<String> queue = new ArrayDeque<>();
        int i,k;

        while(true)
        {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Queue<String> queue = new ArrayDeque<>(); queue new ArrayDeque<>() int i i k; k while(true)
        {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        } true {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        } String input = sc.next(); input sc.next() sc.next sc if(input.equals("-")) break; input.equals("-") input.equals input "-" break; String[] binput = input.split(""); binput input.split("") input.split input "" for(i=0; i<binput.length; i++) queue.add(binput[i]); i=0; i=0 i 0 i<binput.length i binput.length binput binput.length i++ i++ i queue.add(binput[i]); queue.add(binput[i]) queue.add queue binput[i] binput i int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int h; h for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            } i=0; i=0 i 0 i<m i m i++ i++ i {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            } {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            } h = sc.nextInt() h sc.nextInt() sc.nextInt sc for(k=0; k<h; k++) queue.add(queue.poll()); k=0; k=0 k 0 k<h k h k++ k++ k queue.add(queue.poll()); queue.add(queue.poll()) queue.add queue queue.poll() queue.poll queue for(String a : queue) System.out.printf("%s",a); String a queue System.out.printf("%s",a); System.out.printf("%s",a) System.out.printf System.out System System.out "%s" a System.out.printf("\n") System.out.printf System.out System System.out "\n" queue.clear() queue.clear queue sc.close() sc.close sc String[] args args public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Queue<String> queue = new ArrayDeque<>();
        int i,k;

        while(true)
        {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        }
        sc.close();
    }
} public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Queue<String> queue = new ArrayDeque<>();
        int i,k;

        while(true)
        {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        }
        sc.close();
    }
} Main
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Queue<String> queue = new ArrayDeque<>();
        int i,k;

        while(true)
        {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        }
        sc.close();
    }
}
