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

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String str = br.readLine();

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

			int num = Integer.parseInt(br.readLine());

			for(int i = 0; i < num; i++){
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			}

			sb.append(str + "\n");

		}

		System.out.print(sb);

	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String str = br.readLine();

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

			int num = Integer.parseInt(br.readLine());

			for(int i = 0; i < num; i++){
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			}

			sb.append(str + "\n");

		}

		System.out.print(sb);

	}
} Main public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String str = br.readLine();

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

			int num = Integer.parseInt(br.readLine());

			for(int i = 0; i < num; i++){
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			}

			sb.append(str + "\n");

		}

		System.out.print(sb);

	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String str = br.readLine();

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

			int num = Integer.parseInt(br.readLine());

			for(int i = 0; i < num; i++){
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			}

			sb.append(str + "\n");

		}

		System.out.print(sb);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true){

			String str = br.readLine();

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

			int num = Integer.parseInt(br.readLine());

			for(int i = 0; i < num; i++){
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			}

			sb.append(str + "\n");

		} true {

			String str = br.readLine();

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

			int num = Integer.parseInt(br.readLine());

			for(int i = 0; i < num; i++){
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			}

			sb.append(str + "\n");

		} String str = br.readLine(); str br.readLine() br.readLine br if(str.equals("-")){
				break;
			} str.equals("-") str.equals str "-" {
				break;
			} break; int num = Integer.parseInt(br.readLine()); num Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i = 0; i < num; i++){
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			} {
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			} int len = Integer.parseInt(br.readLine()); len Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br String bottom = str.substring(0, len); bottom str.substring(0, len) str.substring str 0 len String top = str.substring(len); top str.substring(len) str.substring str len str = top + bottom str top + bottom top bottom sb.append(str + "\n") sb.append sb str + "\n" str "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String str = br.readLine();

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

			int num = Integer.parseInt(br.readLine());

			for(int i = 0; i < num; i++){
				int len = Integer.parseInt(br.readLine());
				String bottom = str.substring(0, len);
				String top = str.substring(len);
				str = top + bottom;
			}

			sb.append(str + "\n");

		}

		System.out.print(sb);

	}
}