using System;

class Sample34
{
    public static void Main()
    {
        while (true)
        {
            string letters = Console.ReadLine().Trim();
            int dataSet = 0;
            int lettersLength = letters.Length;

            //out of range about the length of string .
            try
            {
                if(lettersLength < 1 || 200 < lettersLength)
                {
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch( ArgumentOutOfRangeException e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("文字列の長さが範囲外です。");
                Environment.Exit(0);
            }

            //終了処理
            if (letters == "-")
            {
                break;
            }

            string inputShuffle = Console.ReadLine().Trim();
            int shuffle = 0;

            //parse int
            try
            {
                shuffle = int.Parse(inputShuffle);

            }
            catch(FormatException e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("シャッフル数は数字で入力してください。");
                Environment.Exit(0);

            }

            //out of range about the number of shuffle.
            try
            {
                if (shuffle < 1 || 100 < shuffle)
                {
                    throw new ArgumentOutOfRangeException();
                }

            }
            catch(ArgumentOutOfRangeException e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("シャッフルの数が範囲外です。");
                Environment.Exit(0);
            }

            //shuffle and console write.
            for (int i = 0; i < shuffle; i++)
            {
                string inputHands = Console.ReadLine().Trim();

                //parse int and out of range about the hands.
                try
                {
                    var hands = int.Parse(inputHands);

                    if (hands < 1 || lettersLength <= hands)
                    {
                        throw new ArgumentOutOfRangeException();
                    }

                    letters = letters.Remove(0, hands) + letters.Substring(0, hands);
                }
                catch(FormatException e)
                {
                    Console.WriteLine("シャッフル場所の指定は数字でおこなってください。");
                    Environment.Exit(0);
                }
                catch (ArgumentOutOfRangeException e)
                {
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine("シャッフルの数が範囲外です。");
                    Environment.Exit(0);

                }
            }

            Console.WriteLine(letters);

            dataSet++;

            //out of range about data set.
            try
            {
                if (10 < dataSet)
                {
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("データセットの数が範囲外です。");
                Environment.Exit(0);
            }

        }

    }

}


Measured memory_bytes: 15932