
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		//?????£????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		while(true){
			String moji = sc.next();

			//?????????-?????£????????????
			if(moji.equals("-")){
				break;
			}

			//??°??????????????°???????????????
			int h = sc.nextInt();

			//
			for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			}

			System.out.println(moji);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String args[]){

		//?????£????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		while(true){
			String moji = sc.next();

			//?????????-?????£????????????
			if(moji.equals("-")){
				break;
			}

			//??°??????????????°???????????????
			int h = sc.nextInt();

			//
			for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			}

			System.out.println(moji);
		}
	}
} Main public static void main(String args[]){

		//?????£????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		while(true){
			String moji = sc.next();

			//?????????-?????£????????????
			if(moji.equals("-")){
				break;
			}

			//??°??????????????°???????????????
			int h = sc.nextInt();

			//
			for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			}

			System.out.println(moji);
		}
	} main {

		//?????£????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		while(true){
			String moji = sc.next();

			//?????????-?????£????????????
			if(moji.equals("-")){
				break;
			}

			//??°??????????????°???????????????
			int h = sc.nextInt();

			//
			for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			}

			System.out.println(moji);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
			String moji = sc.next();

			//?????????-?????£????????????
			if(moji.equals("-")){
				break;
			}

			//??°??????????????°???????????????
			int h = sc.nextInt();

			//
			for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			}

			System.out.println(moji);
		} true {
			String moji = sc.next();

			//?????????-?????£????????????
			if(moji.equals("-")){
				break;
			}

			//??°??????????????°???????????????
			int h = sc.nextInt();

			//
			for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			}

			System.out.println(moji);
		} String moji = sc.next(); moji sc.next() sc.next sc if(moji.equals("-")){
				break;
			} moji.equals("-") moji.equals moji "-" {
				break;
			} break; int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			} int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			} {
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			} int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc String left = moji.substring(0,c); left moji.substring(0,c) moji.substring moji 0 c String right = moji.substring(c); right moji.substring(c) moji.substring moji c moji = right + left moji right + left right left System.out.println(moji) System.out.println System.out System System.out moji String args[] args public class Main {
	public static void main(String args[]){

		//?????£????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		while(true){
			String moji = sc.next();

			//?????????-?????£????????????
			if(moji.equals("-")){
				break;
			}

			//??°??????????????°???????????????
			int h = sc.nextInt();

			//
			for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			}

			System.out.println(moji);
		}
	}
} public class Main {
	public static void main(String args[]){

		//?????£????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		while(true){
			String moji = sc.next();

			//?????????-?????£????????????
			if(moji.equals("-")){
				break;
			}

			//??°??????????????°???????????????
			int h = sc.nextInt();

			//
			for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			}

			System.out.println(moji);
		}
	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		//?????£????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		while(true){
			String moji = sc.next();

			//?????????-?????£????????????
			if(moji.equals("-")){
				break;
			}

			//??°??????????????°???????????????
			int h = sc.nextInt();

			//
			for(int i = 0; i < h; i++){
				int c = sc.nextInt();

				String left = moji.substring(0,c);
				String right = moji.substring(c);

				moji = right + left ;
			}

			System.out.println(moji);
		}
	}
}