import java.util.Scanner;

public class Main {

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

		StringBuffer cards = new StringBuffer(sc.next());
		
		for (; !cards.toString().equals("-"); cards = new StringBuffer(sc.next())) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		}
		
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

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

		StringBuffer cards = new StringBuffer(sc.next());
		
		for (; !cards.toString().equals("-"); cards = new StringBuffer(sc.next())) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

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

		StringBuffer cards = new StringBuffer(sc.next());
		
		for (; !cards.toString().equals("-"); cards = new StringBuffer(sc.next())) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		}
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in); 

		StringBuffer cards = new StringBuffer(sc.next());
		
		for (; !cards.toString().equals("-"); cards = new StringBuffer(sc.next())) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		}
		
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuffer cards = new StringBuffer(sc.next()); cards new StringBuffer(sc.next()) for (; !cards.toString().equals("-"); cards = new StringBuffer(sc.next())) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		} ; !cards.toString().equals("-") cards.toString().equals("-") cards.toString().equals cards.toString() cards.toString cards "-" cards = new StringBuffer(sc.next()) cards = new StringBuffer(sc.next()) cards new StringBuffer(sc.next()) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		} {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		} int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int sum = 0; sum 0 for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				sum += sc.nextInt();
			} {
				sum += sc.nextInt();
			} sum += sc.nextInt() sum sc.nextInt() sc.nextInt sc sum = sum % cards.length() sum sum % cards.length() sum cards.length() cards.length cards cards = cards.append(cards.substring(0, sum)) cards cards.append(cards.substring(0, sum)) cards.append cards cards.substring(0, sum) cards.substring cards 0 sum cards.delete(0, sum) cards.delete cards 0 sum System.out.println(cards) System.out.println System.out System System.out cards sc.close() sc.close sc String[] args args public class Main {

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

		StringBuffer cards = new StringBuffer(sc.next());
		
		for (; !cards.toString().equals("-"); cards = new StringBuffer(sc.next())) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		}
		
		sc.close();
	}
} public class Main {

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

		StringBuffer cards = new StringBuffer(sc.next());
		
		for (; !cards.toString().equals("-"); cards = new StringBuffer(sc.next())) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		}
		
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

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

		StringBuffer cards = new StringBuffer(sc.next());
		
		for (; !cards.toString().equals("-"); cards = new StringBuffer(sc.next())) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		}
		
		sc.close();
	}
}