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

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("-")) {
				break;
			}
		}
		List<String> mozilist = new ArrayList<String>();
		List<Integer> kazulist = new ArrayList<Integer>();

		for (String string : klist) {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		}

		int i = 0;
		int count = i;
		int nannkai = 0;
		for (String string : mozilist) {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		}
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("-")) {
				break;
			}
		}
		List<String> mozilist = new ArrayList<String>();
		List<Integer> kazulist = new ArrayList<Integer>();

		for (String string : klist) {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		}

		int i = 0;
		int count = i;
		int nannkai = 0;
		for (String string : mozilist) {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		}
	}
} Main public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("-")) {
				break;
			}
		}
		List<String> mozilist = new ArrayList<String>();
		List<Integer> kazulist = new ArrayList<Integer>();

		for (String string : klist) {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		}

		int i = 0;
		int count = i;
		int nannkai = 0;
		for (String string : mozilist) {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		}
	} main {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("-")) {
				break;
			}
		}
		List<String> mozilist = new ArrayList<String>();
		List<Integer> kazulist = new ArrayList<Integer>();

		for (String string : klist) {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		}

		int i = 0;
		int count = i;
		int nannkai = 0;
		for (String string : mozilist) {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<String> klist = new ArrayList<String>(); klist new ArrayList<String>() while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("-")) {
				break;
			}
		} true {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("-")) {
				break;
			}
		} String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc klist.add(line) klist.add klist line if (line.equals("-")) {
				break;
			} line.equals("-") line.equals line "-" {
				break;
			} break; List<String> mozilist = new ArrayList<String>(); mozilist new ArrayList<String>() List<Integer> kazulist = new ArrayList<Integer>(); kazulist new ArrayList<Integer>() for (String string : klist) {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		} String string klist {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		} {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		} if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			} string.matches("^[0-9]*$") string.matches string "^[0-9]*$" {
				kazulist.add(Integer.parseInt(string));
			} kazulist.add(Integer.parseInt(string)) kazulist.add kazulist Integer.parseInt(string) Integer.parseInt Integer string {
				mozilist.add(string);
			} mozilist.add(string) mozilist.add mozilist string int i = 0; i 0 int count = i; count i int nannkai = 0; nannkai 0 for (String string : mozilist) {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		} String string mozilist {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		} {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		} if (string.equals("-")) {
				break;
			} string.equals("-") string.equals string "-" {
				break;
			} break; for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			} int j = 1; int j = 1; j 1 j <= kazulist.get(i) j kazulist.get(i) kazulist.get kazulist i j++ j++ j {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			} {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			} StringBuilder r = new StringBuilder(); r new StringBuilder() r.append(string.substring( kazulist.get(j+i))) r.append r string.substring( kazulist.get(j+i)) string.substring string kazulist.get(j+i) kazulist.get kazulist j+i j i r.append(string.substring(0,kazulist.get(j+i))) r.append r string.substring(0,kazulist.get(j+i)) string.substring string 0 kazulist.get(j+i) kazulist.get kazulist j+i j i string = r.toString() string r.toString() r.toString r count++ count nannkai++ nannkai i = count+nannkai i count+nannkai count nannkai System.out.println(string) System.out.println System.out System System.out string String[] arges arges public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("-")) {
				break;
			}
		}
		List<String> mozilist = new ArrayList<String>();
		List<Integer> kazulist = new ArrayList<Integer>();

		for (String string : klist) {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		}

		int i = 0;
		int count = i;
		int nannkai = 0;
		for (String string : mozilist) {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		}
	}
} public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("-")) {
				break;
			}
		}
		List<String> mozilist = new ArrayList<String>();
		List<Integer> kazulist = new ArrayList<Integer>();

		for (String string : klist) {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		}

		int i = 0;
		int count = i;
		int nannkai = 0;
		for (String string : mozilist) {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		}
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("-")) {
				break;
			}
		}
		List<String> mozilist = new ArrayList<String>();
		List<Integer> kazulist = new ArrayList<Integer>();

		for (String string : klist) {
			if (string.matches("^[0-9]*$")) {
				kazulist.add(Integer.parseInt(string));
			} else {
				mozilist.add(string);
			}
		}

		int i = 0;
		int count = i;
		int nannkai = 0;
		for (String string : mozilist) {

			if (string.equals("-")) {
				break;
			}
			;
			for (int j = 1; j <= kazulist.get(i); j++) {

				StringBuilder r = new StringBuilder();
				r.append(string.substring( kazulist.get(j+i)));
				r.append(string.substring(0,kazulist.get(j+i)));
				string = r.toString();
				count++;
			}
			nannkai++;
			i = count+nannkai;
			System.out.println(string);
		}
	}
}