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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn =scan.nextLine();
		int intLoop = 0;
		int intSplit = 0;
		String strAns = "";
		String strTemp = "";
		ArrayList<String> list = new ArrayList<String>();
		while(!"-".equals(strIn)){
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn =scan.nextLine();
		int intLoop = 0;
		int intSplit = 0;
		String strAns = "";
		String strTemp = "";
		ArrayList<String> list = new ArrayList<String>();
		while(!"-".equals(strIn)){
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn =scan.nextLine();
		int intLoop = 0;
		int intSplit = 0;
		String strAns = "";
		String strTemp = "";
		ArrayList<String> list = new ArrayList<String>();
		while(!"-".equals(strIn)){
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		String strIn =scan.nextLine();
		int intLoop = 0;
		int intSplit = 0;
		String strAns = "";
		String strTemp = "";
		ArrayList<String> list = new ArrayList<String>();
		while(!"-".equals(strIn)){
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String strIn =scan.nextLine(); strIn scan.nextLine() scan.nextLine scan int intLoop = 0; intLoop 0 int intSplit = 0; intSplit 0 String strAns = ""; strAns "" String strTemp = ""; strTemp "" ArrayList<String> list = new ArrayList<String>(); list new ArrayList<String>() while(!"-".equals(strIn)){
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		} !"-".equals(strIn) "-".equals(strIn) "-".equals "-" strIn {
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		} intLoop = scan.nextInt() intLoop scan.nextInt() scan.nextInt scan for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			} int i = 0; int i = 0; i 0 i < intLoop i intLoop i++ i++ i {
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			} {
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			} intSplit = scan.nextInt() intSplit scan.nextInt() scan.nextInt scan strTemp = "" strTemp "" strAns ="" strAns "" for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				} int j = 0; int j = 0; j 0 j < strIn.length() j strIn.length() strIn.length strIn j++ j++ j {

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				} {

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				} if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					} j < intSplit j intSplit {
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					} strTemp += strIn.charAt(j) strTemp strIn.charAt(j) strIn.charAt strIn j {
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					} strAns += strIn.charAt(j) strAns strIn.charAt(j) strIn.charAt strIn j strIn = strAns + strTemp strIn strAns + strTemp strAns strTemp list.add(strIn) list.add list strIn strIn =scan.next() strIn scan.next() scan.next scan for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		} int i = 0; int i = 0; i 0 i < list.size() i list.size() list.size list i++ i++ i {
			System.out.println(list.get(i));
		} {
			System.out.println(list.get(i));
		} System.out.println(list.get(i)) System.out.println System.out System System.out list.get(i) list.get list i scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn =scan.nextLine();
		int intLoop = 0;
		int intSplit = 0;
		String strAns = "";
		String strTemp = "";
		ArrayList<String> list = new ArrayList<String>();
		while(!"-".equals(strIn)){
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn =scan.nextLine();
		int intLoop = 0;
		int intSplit = 0;
		String strAns = "";
		String strTemp = "";
		ArrayList<String> list = new ArrayList<String>();
		while(!"-".equals(strIn)){
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn =scan.nextLine();
		int intLoop = 0;
		int intSplit = 0;
		String strAns = "";
		String strTemp = "";
		ArrayList<String> list = new ArrayList<String>();
		while(!"-".equals(strIn)){
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
}