import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2;
		String str3;
		
		while(!str1.equals("-"))
		{
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2;
		String str3;
		
		while(!str1.equals("-"))
		{
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		}
	}
} Main public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2;
		String str3;
		
		while(!str1.equals("-"))
		{
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		}
	} main {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2;
		String str3;
		
		while(!str1.equals("-"))
		{
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str1 = scan.next(); str1 scan.next() scan.next scan String str2; str2 String str3; str3 while(!str1.equals("-"))
		{
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		} !str1.equals("-") str1.equals("-") str1.equals str1 "-" {
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		} int[] shuffle = new int[scan.nextInt()]; shuffle new int[scan.nextInt()] scan.nextInt() scan.nextInt scan for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();} int i = 0; int i = 0; i 0 i < shuffle.length i shuffle.length shuffle shuffle.length i++ i++ i {shuffle[i] = scan.nextInt();} {shuffle[i] = scan.nextInt();} shuffle[i] = scan.nextInt() shuffle[i] shuffle i scan.nextInt() scan.nextInt scan for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			} int i = 0; int i = 0; i 0 i < shuffle.length i shuffle.length shuffle shuffle.length i++ i++ i {
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			} {
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			} str2 = str1.substring(0,shuffle[i]) str2 str1.substring(0,shuffle[i]) str1.substring str1 0 shuffle[i] shuffle i str3 = str1.substring(shuffle[i], str1.length()) str3 str1.substring(shuffle[i], str1.length()) str1.substring str1 shuffle[i] shuffle i str1.length() str1.length str1 StringBuilder buf = new StringBuilder(); buf new StringBuilder() buf.append(str3) buf.append buf str3 buf.append(str2) buf.append buf str2 str1 = buf.toString() str1 buf.toString() buf.toString buf System.out.println(str1) System.out.println System.out System System.out str1 str1 = scan.next() str1 scan.next() scan.next scan String[] args args public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2;
		String str3;
		
		while(!str1.equals("-"))
		{
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		}
	}
} public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2;
		String str3;
		
		while(!str1.equals("-"))
		{
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2;
		String str3;
		
		while(!str1.equals("-"))
		{
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		}
	}
}