import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
		static int CARD_MAX=200;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<String> str =new ArrayList<String>();


		for(int i=0;;i++){
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		}

		for (String st : str){
			System.out.println(st);
		}

	}



public static String shutffleString(String str,int h){
		String before = new String();
		String after = new String();

		for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		}
		for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		}
			str = after + before;

	return str;
}

} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
		static int CARD_MAX=200;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<String> str =new ArrayList<String>();


		for(int i=0;;i++){
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		}

		for (String st : str){
			System.out.println(st);
		}

	}



public static String shutffleString(String str,int h){
		String before = new String();
		String after = new String();

		for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		}
		for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		}
			str = after + before;

	return str;
}

} Main static int CARD_MAX=200; CARD_MAX 200 public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<String> str =new ArrayList<String>();


		for(int i=0;;i++){
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		}

		for (String st : str){
			System.out.println(st);
		}

	} main {
		Scanner scan = new Scanner(System.in);
		List<String> str =new ArrayList<String>();


		for(int i=0;;i++){
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		}

		for (String st : str){
			System.out.println(st);
		}

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) List<String> str =new ArrayList<String>(); str new ArrayList<String>() for(int i=0;;i++){
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		} int i=0; int i=0; i 0 i++ i++ i {
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		} {
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		} str.add(scan.next()) str.add str scan.next() scan.next scan if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 } str.get(i).equals("-") str.get(i).equals str.get(i) str.get str i "-" {
				 str.remove(i);
				 break;
			 } str.remove(i) str.remove str i break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 } scan.hasNextInt() scan.hasNextInt scan {
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 } int h =  scan.nextInt(); h scan.nextInt() scan.nextInt scan str.set(i,shutffleString(str.get(i),h)) str.set str i shutffleString(str.get(i),h) shutffleString str.get(i) str.get str i h for (String st : str){
			System.out.println(st);
		} String st str {
			System.out.println(st);
		} {
			System.out.println(st);
		} System.out.println(st) System.out.println System.out System System.out st String[] args args public static String shutffleString(String str,int h){
		String before = new String();
		String after = new String();

		for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		}
		for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		}
			str = after + before;

	return str;
} shutffleString {
		String before = new String();
		String after = new String();

		for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		}
		for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		}
			str = after + before;

	return str;
} String before = new String(); before new String() String after = new String(); after new String() for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		} int i = 0 ; int i = 0 ; i 0 i<h i h i++ i++ i {
			before = before + str.charAt(i);
		} {
			before = before + str.charAt(i);
		} before = before + str.charAt(i) before before + str.charAt(i) before str.charAt(i) str.charAt str i for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		} int i=h ; int i=h ; i h i < str.length() i str.length() str.length str i++ i++ i {
			after = after + str.charAt(i);
		} {
			after = after + str.charAt(i);
		} after = after + str.charAt(i) after after + str.charAt(i) after str.charAt(i) str.charAt str i str = after + before str after + before after before return str; str String str str int h h public class Main {
		static int CARD_MAX=200;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<String> str =new ArrayList<String>();


		for(int i=0;;i++){
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		}

		for (String st : str){
			System.out.println(st);
		}

	}



public static String shutffleString(String str,int h){
		String before = new String();
		String after = new String();

		for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		}
		for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		}
			str = after + before;

	return str;
}

} public class Main {
		static int CARD_MAX=200;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<String> str =new ArrayList<String>();


		for(int i=0;;i++){
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		}

		for (String st : str){
			System.out.println(st);
		}

	}



public static String shutffleString(String str,int h){
		String before = new String();
		String after = new String();

		for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		}
		for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		}
			str = after + before;

	return str;
}

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
		static int CARD_MAX=200;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<String> str =new ArrayList<String>();


		for(int i=0;;i++){
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		}

		for (String st : str){
			System.out.println(st);
		}

	}



public static String shutffleString(String str,int h){
		String before = new String();
		String after = new String();

		for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		}
		for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		}
			str = after + before;

	return str;
}

}