import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		while(true)
		{
			String word=input.nextLine();
			if(word.equals("-"))
				break;
			int wrapTime=input.nextInt();
			for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			}
			input.nextLine();
			System.out.println(word);
		}
	}

}
 import java.util.Scanner; Scanner java.util public class Main {
	
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		while(true)
		{
			String word=input.nextLine();
			if(word.equals("-"))
				break;
			int wrapTime=input.nextInt();
			for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			}
			input.nextLine();
			System.out.println(word);
		}
	}

} Main public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		while(true)
		{
			String word=input.nextLine();
			if(word.equals("-"))
				break;
			int wrapTime=input.nextInt();
			for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			}
			input.nextLine();
			System.out.println(word);
		}
	} main {
		Scanner input=new Scanner(System.in);
		while(true)
		{
			String word=input.nextLine();
			if(word.equals("-"))
				break;
			int wrapTime=input.nextInt();
			for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			}
			input.nextLine();
			System.out.println(word);
		}
	} Scanner input=new Scanner(System.in); input new Scanner(System.in) while(true)
		{
			String word=input.nextLine();
			if(word.equals("-"))
				break;
			int wrapTime=input.nextInt();
			for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			}
			input.nextLine();
			System.out.println(word);
		} true {
			String word=input.nextLine();
			if(word.equals("-"))
				break;
			int wrapTime=input.nextInt();
			for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			}
			input.nextLine();
			System.out.println(word);
		} String word=input.nextLine(); word input.nextLine() input.nextLine input if(word.equals("-"))
				break; word.equals("-") word.equals word "-" break; int wrapTime=input.nextInt(); wrapTime input.nextInt() input.nextInt input for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			} int i=0; int i=0; i 0 i<wrapTime i wrapTime i++ i++ i {
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			} {
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			} int index=input.nextInt(); index input.nextInt() input.nextInt input String move=word.substring(0,index); move word.substring(0,index) word.substring word 0 index String left=word.substring(index); left word.substring(index) word.substring word index word=left+move word left+move left move input.nextLine() input.nextLine input System.out.println(word) System.out.println System.out System System.out word String[] args args public class Main {
	
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		while(true)
		{
			String word=input.nextLine();
			if(word.equals("-"))
				break;
			int wrapTime=input.nextInt();
			for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			}
			input.nextLine();
			System.out.println(word);
		}
	}

} public class Main {
	
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		while(true)
		{
			String word=input.nextLine();
			if(word.equals("-"))
				break;
			int wrapTime=input.nextInt();
			for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			}
			input.nextLine();
			System.out.println(word);
		}
	}

} Main
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		while(true)
		{
			String word=input.nextLine();
			if(word.equals("-"))
				break;
			int wrapTime=input.nextInt();
			for(int i=0;i<wrapTime;i++)
			{
				int index=input.nextInt();
				String move=word.substring(0,index);
				String left=word.substring(index);
				word=left+move;
				
			}
			input.nextLine();
			System.out.println(word);
		}
	}

}

