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


public class Main
{
	public static void main(String[] args)
	{
		
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shuff(String s , int[] h , int l)
	{
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for(int i = 0 ; i < l ; i++)
		{
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		}
		System.out.println(sb.toString());
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main
{
	public static void main(String[] args)
	{
		
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shuff(String s , int[] h , int l)
	{
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for(int i = 0 ; i < l ; i++)
		{
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		}
		System.out.println(sb.toString());
	}
} Main public static void main(String[] args)
	{
		
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		}catch(IOException e){
			e.printStackTrace();
		}
	} main {
		
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		}catch(IOException e){
			e.printStackTrace();
		}
	} try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		}catch(IOException e){
			e.printStackTrace();
		} catch(IOException e){
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			} !((str =  br.readLine()).equals("-")) ((str =  br.readLine()).equals("-")) (str =  br.readLine()).equals (str =  br.readLine()) str br.readLine() br.readLine br "-" {
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			} int M = Integer.parseInt(br.readLine()); M Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[] arrH = new int[M]; arrH new int[M] M for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				} int i = 0; int i = 0; i 0 i< M i M i++ i++ i {
					arrH[i] = Integer.parseInt(br.readLine());
				} {
					arrH[i] = Integer.parseInt(br.readLine());
				} arrH[i] = Integer.parseInt(br.readLine()) arrH[i] arrH i Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br shuff(str,arrH,M) shuff str arrH M String[] args args public static void shuff(String s , int[] h , int l)
	{
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for(int i = 0 ; i < l ; i++)
		{
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		}
		System.out.println(sb.toString());
	} shuff {
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for(int i = 0 ; i < l ; i++)
		{
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		}
		System.out.println(sb.toString());
	} StringBuilder sb = new StringBuilder(); sb new StringBuilder() sb.append(s) sb.append sb s for(int i = 0 ; i < l ; i++)
		{
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		} int i = 0 ; int i = 0 ; i 0 i < l i l i++ i++ i {
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		} {
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		} sb.append(sb.substring(0,h[i])) sb.append sb sb.substring(0,h[i]) sb.substring sb 0 h[i] h i sb.delete(0,h[i]) sb.delete sb 0 h[i] h i System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb String s s int[] h h int l l public class Main
{
	public static void main(String[] args)
	{
		
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shuff(String s , int[] h , int l)
	{
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for(int i = 0 ; i < l ; i++)
		{
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		}
		System.out.println(sb.toString());
	}
} public class Main
{
	public static void main(String[] args)
	{
		
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shuff(String s , int[] h , int l)
	{
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for(int i = 0 ; i < l ; i++)
		{
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		}
		System.out.println(sb.toString());
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;


public class Main
{
	public static void main(String[] args)
	{
		
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shuff(String s , int[] h , int l)
	{
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for(int i = 0 ; i < l ; i++)
		{
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		}
		System.out.println(sb.toString());
	}
}