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



public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String str, text;
		int num, position;

		try{

			while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			}


		}catch(IOException e){
			System.out.print(e);
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String str, text;
		int num, position;

		try{

			while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			}


		}catch(IOException e){
			System.out.print(e);
		}
	}

} Main public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String str, text;
		int num, position;

		try{

			while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			}


		}catch(IOException e){
			System.out.print(e);
		}
	} main {

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String str, text;
		int num, position;

		try{

			while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			}


		}catch(IOException e){
			System.out.print(e);
		}
	} BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String str str text; text int num num position; position try{

			while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			}


		}catch(IOException e){
			System.out.print(e);
		} catch(IOException e){
			System.out.print(e);
		} IOException e {
			System.out.print(e);
		} System.out.print(e) System.out.print System.out System System.out e {

			while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			}


		} while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			} true {
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			} str=reader.readLine() str reader.readLine() reader.readLine reader if(str.equals("-"))break; str.equals("-") str.equals str "-" break; num=Integer.parseInt(reader.readLine()) num Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				} int i=0; int i=0; i 0 i<num i num i++ i++ i {
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				} {
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				} position=Integer.parseInt(reader.readLine()) position Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader text=str.substring(0, position) text str.substring(0, position) str.substring str 0 position str+=text str text str=str.substring(text.length(), str.length()) str str.substring(text.length(), str.length()) str.substring str text.length() text.length text str.length() str.length str System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String str, text;
		int num, position;

		try{

			while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			}


		}catch(IOException e){
			System.out.print(e);
		}
	}

} public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String str, text;
		int num, position;

		try{

			while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			}


		}catch(IOException e){
			System.out.print(e);
		}
	}

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



public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String str, text;
		int num, position;

		try{

			while(true){
				str=reader.readLine();

				if(str.equals("-"))break;

				num=Integer.parseInt(reader.readLine());

				for(int i=0;i<num;i++){
					position=Integer.parseInt(reader.readLine());

					text=str.substring(0, position);
					str+=text;
					str=str.substring(text.length(), str.length());
				}
				System.out.println(str);

			}


		}catch(IOException e){
			System.out.print(e);
		}
	}

}