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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		String n,sub;

		while(true){
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		}


	}

} 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[] args) throws IOException {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		String n,sub;

		while(true){
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		}


	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		String n,sub;

		while(true){
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		}


	} main {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		String n,sub;

		while(true){
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		}


	} BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); br new BufferedReader( new InputStreamReader(System.in)) String n n sub; sub while(true){
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		} true {
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		} n= br.readLine() n br.readLine() br.readLine br if(n.equals("-")){
				break;
			} n.equals("-") n.equals n "-" {
				break;
			} break; int num = Integer.parseInt(br.readLine()); num Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int h[] = new int[num]; h new int[num] num for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			} int i = 0 ; int i = 0 ; i 0 i < num i num i++ i++ i {
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			} {
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			} h[i]= Integer.parseInt(br.readLine()) h[i] h i Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br sub = n.substring(0, h[i]) sub n.substring(0, h[i]) n.substring n 0 h[i] h i n +=sub n sub n = n.substring(h[i]) n n.substring(h[i]) n.substring n h[i] h i System.out.println(n) System.out.println System.out System System.out n String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		String n,sub;

		while(true){
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		}


	}

} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		String n,sub;

		while(true){
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		}


	}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		String n,sub;

		while(true){
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		}


	}

}