import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
	boolean Judge = true;
  	String end = "-";
  	String work;
  	
  	
  	while( Judge ){
		String deck = scanner.next();		//最初の文字
  		//終わる処理と変換
  		if( deck.equals(end) ){
  			Judge = false;
  			break;
  		}
		int shuffle = scanner.nextInt();	//シャッフル回数
  		//シャッフル
  		for( int i = 0; i < shuffle ; i ++ ) {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		}
  	  	//結果出力
  		System.out.println(deck);
  	}
  	
	
  	//後処理
	scanner.close();
  }
} import java.util.Scanner; Scanner java.util class Main {
  public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
	boolean Judge = true;
  	String end = "-";
  	String work;
  	
  	
  	while( Judge ){
		String deck = scanner.next();		//最初の文字
  		//終わる処理と変換
  		if( deck.equals(end) ){
  			Judge = false;
  			break;
  		}
		int shuffle = scanner.nextInt();	//シャッフル回数
  		//シャッフル
  		for( int i = 0; i < shuffle ; i ++ ) {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		}
  	  	//結果出力
  		System.out.println(deck);
  	}
  	
	
  	//後処理
	scanner.close();
  }
} Main public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
	boolean Judge = true;
  	String end = "-";
  	String work;
  	
  	
  	while( Judge ){
		String deck = scanner.next();		//最初の文字
  		//終わる処理と変換
  		if( deck.equals(end) ){
  			Judge = false;
  			break;
  		}
		int shuffle = scanner.nextInt();	//シャッフル回数
  		//シャッフル
  		for( int i = 0; i < shuffle ; i ++ ) {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		}
  	  	//結果出力
  		System.out.println(deck);
  	}
  	
	
  	//後処理
	scanner.close();
  } main {
	Scanner scanner = new Scanner(System.in);
	boolean Judge = true;
  	String end = "-";
  	String work;
  	
  	
  	while( Judge ){
		String deck = scanner.next();		//最初の文字
  		//終わる処理と変換
  		if( deck.equals(end) ){
  			Judge = false;
  			break;
  		}
		int shuffle = scanner.nextInt();	//シャッフル回数
  		//シャッフル
  		for( int i = 0; i < shuffle ; i ++ ) {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		}
  	  	//結果出力
  		System.out.println(deck);
  	}
  	
	
  	//後処理
	scanner.close();
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) boolean Judge = true; Judge true String end = "-"; end "-" String work; work while( Judge ){
		String deck = scanner.next();		//最初の文字
  		//終わる処理と変換
  		if( deck.equals(end) ){
  			Judge = false;
  			break;
  		}
		int shuffle = scanner.nextInt();	//シャッフル回数
  		//シャッフル
  		for( int i = 0; i < shuffle ; i ++ ) {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		}
  	  	//結果出力
  		System.out.println(deck);
  	} Judge {
		String deck = scanner.next();		//最初の文字
  		//終わる処理と変換
  		if( deck.equals(end) ){
  			Judge = false;
  			break;
  		}
		int shuffle = scanner.nextInt();	//シャッフル回数
  		//シャッフル
  		for( int i = 0; i < shuffle ; i ++ ) {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		}
  	  	//結果出力
  		System.out.println(deck);
  	} String deck = scanner.next(); deck scanner.next() scanner.next scanner if( deck.equals(end) ){
  			Judge = false;
  			break;
  		} deck.equals(end) deck.equals deck end {
  			Judge = false;
  			break;
  		} Judge = false Judge false break; int shuffle = scanner.nextInt(); shuffle scanner.nextInt() scanner.nextInt scanner for( int i = 0; i < shuffle ; i ++ ) {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		} int i = 0; int i = 0; i 0 i < shuffle i shuffle i ++ i ++ i {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		} {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		} int num = scanner.nextInt(); num scanner.nextInt() scanner.nextInt scanner String substr = deck.substring(0, num); substr deck.substring(0, num) deck.substring deck 0 num work = deck.replaceFirst(substr, "") work deck.replaceFirst(substr, "") deck.replaceFirst deck substr "" deck = work.concat(substr) deck work.concat(substr) work.concat work substr System.out.println(deck) System.out.println System.out System System.out deck scanner.close() scanner.close scanner String args[] args
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
	boolean Judge = true;
  	String end = "-";
  	String work;
  	
  	
  	while( Judge ){
		String deck = scanner.next();		//最初の文字
  		//終わる処理と変換
  		if( deck.equals(end) ){
  			Judge = false;
  			break;
  		}
		int shuffle = scanner.nextInt();	//シャッフル回数
  		//シャッフル
  		for( int i = 0; i < shuffle ; i ++ ) {
			int num = scanner.nextInt();	//シャッフル開始位置
			String substr = deck.substring(0, num);
			work = deck.replaceFirst(substr, "");
			deck = work.concat(substr);
  		}
  	  	//結果出力
  		System.out.println(deck);
  	}
  	
	
  	//後処理
	scanner.close();
  }
}
