import java.util.*;

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

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		}
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		}
	}
} Main public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		}
	} main {

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		} ; {
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		} {
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		} String input = scan.next(); input scan.next() scan.next scan if(input.equals("-")){
				break;
			} input.equals("-") input.equals input "-" {
				break;
			} break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan int len = input.length(); len input.length() input.length input StringBuilder sb = new StringBuilder(); sb new StringBuilder() String output = input; output input for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			} {
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			} int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan String s1 = output.substring(0, h); s1 output.substring(0, h) output.substring output 0 h String s2 = output.substring(h, len); s2 output.substring(h, len) output.substring output h len output = s2 + s1 output s2 + s1 s2 s1 System.out.println(output) System.out.println System.out System System.out output String[] args args public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		}
	}
} public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		}
	}
} Main
import java.util.*;

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

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			StringBuilder sb = new StringBuilder();
			String output = input;
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				String s1 = output.substring(0, h);
				String s2 = output.substring(h, len);
				output = s2 + s1;
			}
			System.out.println(output);
		}
	}
}