import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		boolean set = true;

		int count = 0;

		ArrayList<String> result = new ArrayList<String>();

		//シャッフルを始める
		while(set)
		{
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		}
	}
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		boolean set = true;

		int count = 0;

		ArrayList<String> result = new ArrayList<String>();

		//シャッフルを始める
		while(set)
		{
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		}
	}
} Main public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		boolean set = true;

		int count = 0;

		ArrayList<String> result = new ArrayList<String>();

		//シャッフルを始める
		while(set)
		{
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		}
	} main {
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		boolean set = true;

		int count = 0;

		ArrayList<String> result = new ArrayList<String>();

		//シャッフルを始める
		while(set)
		{
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		}
	} BufferedReader input = new BufferedReader (new InputStreamReader (System.in)); input new BufferedReader (new InputStreamReader (System.in)) boolean set = true; set true int count = 0; count 0 ArrayList<String> result = new ArrayList<String>(); result new ArrayList<String>() while(set)
		{
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		} set {
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		} String str = input.readLine(); str input.readLine() input.readLine input if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			} str.equals("-") str.equals str "-" {
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			} for(int num = 0; num < count; num++)
					System.out.println(result.get(num)); int num = 0; int num = 0; num 0 num < count num count num++ num++ num System.out.println(result.get(num)); System.out.println(result.get(num)) System.out.println System.out System System.out result.get(num) result.get result num break; char[] cards = str.toCharArray(); cards str.toCharArray() str.toCharArray str int kaisuu = Integer.parseInt(input.readLine()); kaisuu Integer.parseInt(input.readLine()) Integer.parseInt Integer input.readLine() input.readLine input int[] maisuu = new int[kaisuu]; maisuu new int[kaisuu] kaisuu for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine()); int num = 0; int num = 0; num 0 num < kaisuu num kaisuu num++ num++ num maisuu[num] = Integer.parseInt(input.readLine()); maisuu[num] = Integer.parseInt(input.readLine()) maisuu[num] maisuu num Integer.parseInt(input.readLine()) Integer.parseInt Integer input.readLine() input.readLine input char[] over = new char[cards.length]; over new char[cards.length] cards.length cards cards.length for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			} int kai = 0; int kai = 0; kai 0 kai < kaisuu kai kaisuu kai++ kai++ kai {
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			} {
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			} for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				} int mai = 0; int mai = 0; mai 0 mai < cards.length mai cards.length cards cards.length mai++ mai++ mai {
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				} {
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				} if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					} mai + maisuu[kai] < cards.length mai + maisuu[kai] mai maisuu[kai] maisuu kai cards.length cards cards.length over[mai] = cards[mai + maisuu[kai]] over[mai] over mai cards[mai + maisuu[kai]] cards mai + maisuu[kai] mai maisuu[kai] maisuu kai {
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					} over[mai] = cards[mai + maisuu[kai] - cards.length] over[mai] over mai cards[mai + maisuu[kai] - cards.length] cards mai + maisuu[kai] - cards.length mai + maisuu[kai] mai maisuu[kai] maisuu kai cards.length cards cards.length for(int num = 0; num < cards.length; num++)
					cards[num] = over[num]; int num = 0; int num = 0; num 0 num < cards.length num cards.length cards cards.length num++ num++ num cards[num] = over[num]; cards[num] = over[num] cards[num] cards num over[num] over num result.add(String.valueOf(cards)) result.add result String.valueOf(cards) String.valueOf String cards count++ count String[] args args public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		boolean set = true;

		int count = 0;

		ArrayList<String> result = new ArrayList<String>();

		//シャッフルを始める
		while(set)
		{
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		}
	}
} public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		boolean set = true;

		int count = 0;

		ArrayList<String> result = new ArrayList<String>();

		//シャッフルを始める
		while(set)
		{
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		boolean set = true;

		int count = 0;

		ArrayList<String> result = new ArrayList<String>();

		//シャッフルを始める
		while(set)
		{
			//データを入力する
			String str = input.readLine();

			//終了条件
			if(str.equals("-"))
			{
				for(int num = 0; num < count; num++)
					System.out.println(result.get(num));

				break;
			}

			//カードごとに分ける
				char[] cards = str.toCharArray();

			int kaisuu = Integer.parseInt(input.readLine());

			int[] maisuu = new int[kaisuu];

			//カードをとる枚数を入力する
			for(int num = 0; num < kaisuu; num++)
				maisuu[num] = Integer.parseInt(input.readLine());

			char[] over = new char[cards.length];

			//シャッフルする
			for(int kai = 0; kai < kaisuu; kai++)
			{
				for(int mai = 0; mai < cards.length; mai++)
				{
					if(mai + maisuu[kai] < cards.length)
						over[mai] = cards[mai + maisuu[kai]];
					else
					{
						over[mai] = cards[mai + maisuu[kai] - cards.length];
					}
				}

				for(int num = 0; num < cards.length; num++)
					cards[num] = over[num];

			}

			result.add(String.valueOf(cards));

			count++;

		}
	}
}

