import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true){
			String s = scanner.next();
			
			if(s.equals("-")){
				break;
			}
			
			int m = scanner.nextInt();

			for(int i = 0; i < m; i++){
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			}

			System.out.println(s);
		}
	}
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true){
			String s = scanner.next();
			
			if(s.equals("-")){
				break;
			}
			
			int m = scanner.nextInt();

			for(int i = 0; i < m; i++){
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			}

			System.out.println(s);
		}
	}
} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true){
			String s = scanner.next();
			
			if(s.equals("-")){
				break;
			}
			
			int m = scanner.nextInt();

			for(int i = 0; i < m; i++){
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			}

			System.out.println(s);
		}
	} main {
		Scanner scanner = new Scanner(System.in);

		while(true){
			String s = scanner.next();
			
			if(s.equals("-")){
				break;
			}
			
			int m = scanner.nextInt();

			for(int i = 0; i < m; i++){
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			}

			System.out.println(s);
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while(true){
			String s = scanner.next();
			
			if(s.equals("-")){
				break;
			}
			
			int m = scanner.nextInt();

			for(int i = 0; i < m; i++){
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			}

			System.out.println(s);
		} true {
			String s = scanner.next();
			
			if(s.equals("-")){
				break;
			}
			
			int m = scanner.nextInt();

			for(int i = 0; i < m; i++){
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			}

			System.out.println(s);
		} String s = scanner.next(); s scanner.next() scanner.next scanner if(s.equals("-")){
				break;
			} s.equals("-") s.equals s "-" {
				break;
			} break; int m = scanner.nextInt(); m scanner.nextInt() scanner.nextInt scanner for(int i = 0; i < m; i++){
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			} {
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			} int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner s += s.substring(0,n) s s.substring(0,n) s.substring s 0 n s = s.substring(n) s s.substring(n) s.substring s n System.out.println(s) System.out.println System.out System System.out s String[] args args
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while(true){
			String s = scanner.next();
			
			if(s.equals("-")){
				break;
			}
			
			int m = scanner.nextInt();

			for(int i = 0; i < m; i++){
				int n = scanner.nextInt();
				s += s.substring(0,n);
				s = s.substring(n);
			}

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