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

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();

		while(true){
			String mountain = br.readLine();

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

			int m = Integer.parseInt(br.readLine());
			int i = 0;

			for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			}

			sb.append(mountain).append("\n");
		}

		System.out.print(sb);
	}
} 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[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();

		while(true){
			String mountain = br.readLine();

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

			int m = Integer.parseInt(br.readLine());
			int i = 0;

			for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			}

			sb.append(mountain).append("\n");
		}

		System.out.print(sb);
	}
} Main public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();

		while(true){
			String mountain = br.readLine();

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

			int m = Integer.parseInt(br.readLine());
			int i = 0;

			for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			}

			sb.append(mountain).append("\n");
		}

		System.out.print(sb);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();

		while(true){
			String mountain = br.readLine();

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

			int m = Integer.parseInt(br.readLine());
			int i = 0;

			for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			}

			sb.append(mountain).append("\n");
		}

		System.out.print(sb);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuffer sb = new StringBuffer(); sb new StringBuffer() StringBuffer sb2 = new StringBuffer(); sb2 new StringBuffer() while(true){
			String mountain = br.readLine();

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

			int m = Integer.parseInt(br.readLine());
			int i = 0;

			for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			}

			sb.append(mountain).append("\n");
		} true {
			String mountain = br.readLine();

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

			int m = Integer.parseInt(br.readLine());
			int i = 0;

			for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			}

			sb.append(mountain).append("\n");
		} String mountain = br.readLine(); mountain br.readLine() br.readLine br if( mountain.equals("-")) break; mountain.equals("-") mountain.equals mountain "-" break; int m = Integer.parseInt(br.readLine()); m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int i = 0; i 0 for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			} i=0 ; i=0 i 0 i<m i m i++ i++ i {
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			} {
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			} int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h)) sb2.append(mountain.substring(h, mountain.length())).append sb2.append(mountain.substring(h, mountain.length())) sb2.append sb2 mountain.substring(h, mountain.length()) mountain.substring mountain h mountain.length() mountain.length mountain mountain.substring(0, h) mountain.substring mountain 0 h mountain = sb2.toString() mountain sb2.toString() sb2.toString sb2 sb2.setLength(0) sb2.setLength sb2 0 sb.append(mountain).append("\n") sb.append(mountain).append sb.append(mountain) sb.append sb mountain "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] age age public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();

		while(true){
			String mountain = br.readLine();

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

			int m = Integer.parseInt(br.readLine());
			int i = 0;

			for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			}

			sb.append(mountain).append("\n");
		}

		System.out.print(sb);
	}
} public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();

		while(true){
			String mountain = br.readLine();

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

			int m = Integer.parseInt(br.readLine());
			int i = 0;

			for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			}

			sb.append(mountain).append("\n");
		}

		System.out.print(sb);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();

		while(true){
			String mountain = br.readLine();

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

			int m = Integer.parseInt(br.readLine());
			int i = 0;

			for( i=0 ; i<m ; i++ ){
				int h = Integer.parseInt(br.readLine());
				sb2.append(mountain.substring(h, mountain.length())).append(mountain.substring(0, h));
				mountain = sb2.toString();
				sb2.setLength(0);
			}

			sb.append(mountain).append("\n");
		}

		System.out.print(sb);
	}
}