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

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    StringBuilder result = new StringBuilder();
	    while (true) {
		    String line = br.readLine();

		    if ("-".equals(line)) break;

		    int shuffleCount = Integer.parseInt(br.readLine());

		    for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    }
		    result.append(line).append("\n");
	    }
	    System.out.print(result.toString());
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    StringBuilder result = new StringBuilder();
	    while (true) {
		    String line = br.readLine();

		    if ("-".equals(line)) break;

		    int shuffleCount = Integer.parseInt(br.readLine());

		    for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    }
		    result.append(line).append("\n");
	    }
	    System.out.print(result.toString());
	}
} Main public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    StringBuilder result = new StringBuilder();
	    while (true) {
		    String line = br.readLine();

		    if ("-".equals(line)) break;

		    int shuffleCount = Integer.parseInt(br.readLine());

		    for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    }
		    result.append(line).append("\n");
	    }
	    System.out.print(result.toString());
	} main {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    StringBuilder result = new StringBuilder();
	    while (true) {
		    String line = br.readLine();

		    if ("-".equals(line)) break;

		    int shuffleCount = Integer.parseInt(br.readLine());

		    for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    }
		    result.append(line).append("\n");
	    }
	    System.out.print(result.toString());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder result = new StringBuilder(); result new StringBuilder() while (true) {
		    String line = br.readLine();

		    if ("-".equals(line)) break;

		    int shuffleCount = Integer.parseInt(br.readLine());

		    for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    }
		    result.append(line).append("\n");
	    } true {
		    String line = br.readLine();

		    if ("-".equals(line)) break;

		    int shuffleCount = Integer.parseInt(br.readLine());

		    for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    }
		    result.append(line).append("\n");
	    } String line = br.readLine(); line br.readLine() br.readLine br if ("-".equals(line)) break; "-".equals(line) "-".equals "-" line break; int shuffleCount = Integer.parseInt(br.readLine()); shuffleCount Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    } int i = 0; int i = 0; i 0 i < shuffleCount i shuffleCount i++ i++ i {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    } {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    } int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br line = line.substring(h, line.length()) + line.substring(0, h) line line.substring(h, line.length()) + line.substring(0, h) line.substring(h, line.length()) line.substring line h line.length() line.length line line.substring(0, h) line.substring line 0 h result.append(line).append("\n") result.append(line).append result.append(line) result.append result line "\n" System.out.print(result.toString()) System.out.print System.out System System.out result.toString() result.toString result String[] args args public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    StringBuilder result = new StringBuilder();
	    while (true) {
		    String line = br.readLine();

		    if ("-".equals(line)) break;

		    int shuffleCount = Integer.parseInt(br.readLine());

		    for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    }
		    result.append(line).append("\n");
	    }
	    System.out.print(result.toString());
	}
} public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    StringBuilder result = new StringBuilder();
	    while (true) {
		    String line = br.readLine();

		    if ("-".equals(line)) break;

		    int shuffleCount = Integer.parseInt(br.readLine());

		    for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    }
		    result.append(line).append("\n");
	    }
	    System.out.print(result.toString());
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    StringBuilder result = new StringBuilder();
	    while (true) {
		    String line = br.readLine();

		    if ("-".equals(line)) break;

		    int shuffleCount = Integer.parseInt(br.readLine());

		    for (int i = 0; i < shuffleCount; i++) {
		    	int h = Integer.parseInt(br.readLine());
		    	// shuffle
		    	line = line.substring(h, line.length()) + line.substring(0, h);

		    }
		    result.append(line).append("\n");
	    }
	    System.out.print(result.toString());
	}
}