import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			// data input
			String str = sc.next();
			if (str.equals("-"))
			{
				break;
			}
			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			}

			// shuffle
			String after = str;
			String before;
			for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			}

			System.out.println(after);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			// data input
			String str = sc.next();
			if (str.equals("-"))
			{
				break;
			}
			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			}

			// shuffle
			String after = str;
			String before;
			for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			}

			System.out.println(after);
		}
	}
} Main public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			// data input
			String str = sc.next();
			if (str.equals("-"))
			{
				break;
			}
			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			}

			// shuffle
			String after = str;
			String before;
			for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			}

			System.out.println(after);
		}
	} main {
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			// data input
			String str = sc.next();
			if (str.equals("-"))
			{
				break;
			}
			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			}

			// shuffle
			String after = str;
			String before;
			for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			}

			System.out.println(after);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true)
		{
			// data input
			String str = sc.next();
			if (str.equals("-"))
			{
				break;
			}
			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			}

			// shuffle
			String after = str;
			String before;
			for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			}

			System.out.println(after);
		} true {
			// data input
			String str = sc.next();
			if (str.equals("-"))
			{
				break;
			}
			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			}

			// shuffle
			String after = str;
			String before;
			for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			}

			System.out.println(after);
		} String str = sc.next(); str sc.next() sc.next sc if (str.equals("-"))
			{
				break;
			} str.equals("-") str.equals str "-" {
				break;
			} break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] shuffle = new int[m]; shuffle new int[m] m for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				shuffle[i] = sc.nextInt();
			} {
				shuffle[i] = sc.nextInt();
			} shuffle[i] = sc.nextInt() shuffle[i] shuffle i sc.nextInt() sc.nextInt sc String after = str; after str String before; before for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			} {
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			} before = after before after after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]) after before.substring(shuffle[i]) + before.substring(0, shuffle[i]) before.substring(shuffle[i]) before.substring before shuffle[i] shuffle i before.substring(0, shuffle[i]) before.substring before 0 shuffle[i] shuffle i System.out.println(after) System.out.println System.out System System.out after String[] args args public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			// data input
			String str = sc.next();
			if (str.equals("-"))
			{
				break;
			}
			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			}

			// shuffle
			String after = str;
			String before;
			for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			}

			System.out.println(after);
		}
	}
} public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			// data input
			String str = sc.next();
			if (str.equals("-"))
			{
				break;
			}
			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			}

			// shuffle
			String after = str;
			String before;
			for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			}

			System.out.println(after);
		}
	}
} Main
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			// data input
			String str = sc.next();
			if (str.equals("-"))
			{
				break;
			}
			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++)
			{
				shuffle[i] = sc.nextInt();
			}

			// shuffle
			String after = str;
			String before;
			for (int i = 0; i < m; i++)
			{
				before = after;
				after = before.substring(shuffle[i]) + before.substring(0, shuffle[i]);
			}

			System.out.println(after);
		}
	}
}
