import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n;
		int m, h;
		int sum = 0;
		int wordLength = 0;
		int count = 0;
		ArrayList<String> wordsList = new ArrayList<String>();
		ArrayList<Integer> shufflesList = new ArrayList<Integer>();
		while (true) {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		}
		for (int i = 0; i < count; i++) {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n;
		int m, h;
		int sum = 0;
		int wordLength = 0;
		int count = 0;
		ArrayList<String> wordsList = new ArrayList<String>();
		ArrayList<Integer> shufflesList = new ArrayList<Integer>();
		while (true) {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		}
		for (int i = 0; i < count; i++) {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		}
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n;
		int m, h;
		int sum = 0;
		int wordLength = 0;
		int count = 0;
		ArrayList<String> wordsList = new ArrayList<String>();
		ArrayList<Integer> shufflesList = new ArrayList<Integer>();
		while (true) {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		}
		for (int i = 0; i < count; i++) {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String n;
		int m, h;
		int sum = 0;
		int wordLength = 0;
		int count = 0;
		ArrayList<String> wordsList = new ArrayList<String>();
		ArrayList<Integer> shufflesList = new ArrayList<Integer>();
		while (true) {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		}
		for (int i = 0; i < count; i++) {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n; n int m m h; h int sum = 0; sum 0 int wordLength = 0; wordLength 0 int count = 0; count 0 ArrayList<String> wordsList = new ArrayList<String>(); wordsList new ArrayList<String>() ArrayList<Integer> shufflesList = new ArrayList<Integer>(); shufflesList new ArrayList<Integer>() while (true) {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		} true {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		} n = sc.next() n sc.next() sc.next sc if (n.equals("-")) {
				break;
			} n.equals("-") n.equals n "-" {
				break;
			} break; wordsList.add(n) wordsList.add wordsList n m = sc.nextInt() m sc.nextInt() sc.nextInt sc for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				h = sc.nextInt();
				sum += h;
			} {
				h = sc.nextInt();
				sum += h;
			} h = sc.nextInt() h sc.nextInt() sc.nextInt sc sum += h sum h wordLength = sum % n.length() wordLength sum % n.length() sum n.length() n.length n shufflesList.add(wordLength) shufflesList.add shufflesList wordLength sum = 0 sum 0 count++ count for (int i = 0; i < count; i++) {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		} int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		} {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		} char[] array = wordsList.get(i).toCharArray(); array wordsList.get(i).toCharArray() wordsList.get(i).toCharArray wordsList.get(i) wordsList.get wordsList i int shuffle = shufflesList.get(i); shuffle shufflesList.get(i) shufflesList.get shufflesList i for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			} int j = shuffle; int j = shuffle; j shuffle j < array.length j array.length array array.length j++ j++ j {
				System.out.print(array[j]);
			} {
				System.out.print(array[j]);
			} System.out.print(array[j]) System.out.print System.out System System.out array[j] array j for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			} int j = 0; int j = 0; j 0 j < shuffle j shuffle j++ j++ j {
				System.out.print(array[j]);
			} {
				System.out.print(array[j]);
			} System.out.print(array[j]) System.out.print System.out System System.out array[j] array j System.out.println() System.out.println System.out System System.out sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n;
		int m, h;
		int sum = 0;
		int wordLength = 0;
		int count = 0;
		ArrayList<String> wordsList = new ArrayList<String>();
		ArrayList<Integer> shufflesList = new ArrayList<Integer>();
		while (true) {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		}
		for (int i = 0; i < count; i++) {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		}
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n;
		int m, h;
		int sum = 0;
		int wordLength = 0;
		int count = 0;
		ArrayList<String> wordsList = new ArrayList<String>();
		ArrayList<Integer> shufflesList = new ArrayList<Integer>();
		while (true) {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		}
		for (int i = 0; i < count; i++) {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		}
		sc.close();
	}
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n;
		int m, h;
		int sum = 0;
		int wordLength = 0;
		int count = 0;
		ArrayList<String> wordsList = new ArrayList<String>();
		ArrayList<Integer> shufflesList = new ArrayList<Integer>();
		while (true) {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		}
		for (int i = 0; i < count; i++) {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		}
		sc.close();
	}
}
