import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String str;
		String sh_str;
		int sh_num;
		int[] sh;

		Scanner sc= new Scanner( System.in );

		while ( true) {
			sh_num = 0;
			str = sc.next();

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

			sh_num  = sc.nextInt();

			sh = new int[sh_num];

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			}

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			}
			System.out.println( str );
		}

		sc.close();
	}
}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		String str;
		String sh_str;
		int sh_num;
		int[] sh;

		Scanner sc= new Scanner( System.in );

		while ( true) {
			sh_num = 0;
			str = sc.next();

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

			sh_num  = sc.nextInt();

			sh = new int[sh_num];

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			}

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			}
			System.out.println( str );
		}

		sc.close();
	}
} Main public static void main(String[] args) {

		String str;
		String sh_str;
		int sh_num;
		int[] sh;

		Scanner sc= new Scanner( System.in );

		while ( true) {
			sh_num = 0;
			str = sc.next();

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

			sh_num  = sc.nextInt();

			sh = new int[sh_num];

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			}

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			}
			System.out.println( str );
		}

		sc.close();
	} main {

		String str;
		String sh_str;
		int sh_num;
		int[] sh;

		Scanner sc= new Scanner( System.in );

		while ( true) {
			sh_num = 0;
			str = sc.next();

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

			sh_num  = sc.nextInt();

			sh = new int[sh_num];

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			}

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			}
			System.out.println( str );
		}

		sc.close();
	} String str; str String sh_str; sh_str int sh_num; sh_num int[] sh; sh Scanner sc= new Scanner( System.in ); sc new Scanner( System.in ) while ( true) {
			sh_num = 0;
			str = sc.next();

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

			sh_num  = sc.nextInt();

			sh = new int[sh_num];

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			}

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			}
			System.out.println( str );
		} true {
			sh_num = 0;
			str = sc.next();

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

			sh_num  = sc.nextInt();

			sh = new int[sh_num];

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			}

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			}
			System.out.println( str );
		} sh_num = 0 sh_num 0 str = sc.next() str sc.next() sc.next sc if ( str.equals("-") ) {
				break;
			} str.equals("-") str.equals str "-" {
				break;
			} break; sh_num  = sc.nextInt() sh_num sc.nextInt() sc.nextInt sc sh = new int[sh_num] sh new int[sh_num] sh_num for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			} int i = 0 ; int i = 0 ; i 0 i < sh_num i sh_num i++ i++ i {
				sh[i]= sc.nextInt();
			} {
				sh[i]= sc.nextInt();
			} sh[i]= sc.nextInt() sh[i] sh i sc.nextInt() sc.nextInt sc for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			} int i = 0 ; int i = 0 ; i 0 i < sh_num i sh_num i++ i++ i {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			} {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			} sh_str = "" sh_str "" sh_str += str.substring(sh[i],str.length()) sh_str str.substring(sh[i],str.length()) str.substring str sh[i] sh i str.length() str.length str sh_str += str.substring(0,(sh[i])) sh_str str.substring(0,(sh[i])) str.substring str 0 (sh[i]) sh i str = sh_str str sh_str System.out.println( str ) System.out.println System.out System System.out str sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {

		String str;
		String sh_str;
		int sh_num;
		int[] sh;

		Scanner sc= new Scanner( System.in );

		while ( true) {
			sh_num = 0;
			str = sc.next();

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

			sh_num  = sc.nextInt();

			sh = new int[sh_num];

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			}

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			}
			System.out.println( str );
		}

		sc.close();
	}
} public class Main {

	public static void main(String[] args) {

		String str;
		String sh_str;
		int sh_num;
		int[] sh;

		Scanner sc= new Scanner( System.in );

		while ( true) {
			sh_num = 0;
			str = sc.next();

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

			sh_num  = sc.nextInt();

			sh = new int[sh_num];

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			}

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			}
			System.out.println( str );
		}

		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String str;
		String sh_str;
		int sh_num;
		int[] sh;

		Scanner sc= new Scanner( System.in );

		while ( true) {
			sh_num = 0;
			str = sc.next();

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

			sh_num  = sc.nextInt();

			sh = new int[sh_num];

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh[i]= sc.nextInt();
			}

			for ( int i = 0 ; i < sh_num ; i++ ) {
				sh_str = "";

				sh_str += str.substring(sh[i],str.length());
				sh_str += str.substring(0,(sh[i]));

				str = sh_str;
			}
			System.out.println( str );
		}

		sc.close();
	}
}

