import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String n = scan.nextLine();
	while (!n.equals("-")) {
	    int m = scan.nextInt();
	    scan.nextLine();
	    String newN = n;
	    for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    }
	    System.out.println(newN);
	    n = scan.nextLine();
	}
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String n = scan.nextLine();
	while (!n.equals("-")) {
	    int m = scan.nextInt();
	    scan.nextLine();
	    String newN = n;
	    for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    }
	    System.out.println(newN);
	    n = scan.nextLine();
	}
    }
} Main public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String n = scan.nextLine();
	while (!n.equals("-")) {
	    int m = scan.nextInt();
	    scan.nextLine();
	    String newN = n;
	    for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    }
	    System.out.println(newN);
	    n = scan.nextLine();
	}
    } main {
	Scanner scan = new Scanner(System.in);
	String n = scan.nextLine();
	while (!n.equals("-")) {
	    int m = scan.nextInt();
	    scan.nextLine();
	    String newN = n;
	    for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    }
	    System.out.println(newN);
	    n = scan.nextLine();
	}
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String n = scan.nextLine(); n scan.nextLine() scan.nextLine scan while (!n.equals("-")) {
	    int m = scan.nextInt();
	    scan.nextLine();
	    String newN = n;
	    for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    }
	    System.out.println(newN);
	    n = scan.nextLine();
	} !n.equals("-") n.equals("-") n.equals n "-" {
	    int m = scan.nextInt();
	    scan.nextLine();
	    String newN = n;
	    for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    }
	    System.out.println(newN);
	    n = scan.nextLine();
	} int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan scan.nextLine() scan.nextLine scan String newN = n; newN n for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    } {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    } String hs = scan.nextLine(); hs scan.nextLine() scan.nextLine scan int h = Integer.valueOf(hs); h Integer.valueOf(hs) Integer.valueOf Integer hs newN = newN.substring(h, newN.length()) + newN.substring(0, h) newN newN.substring(h, newN.length()) + newN.substring(0, h) newN.substring(h, newN.length()) newN.substring newN h newN.length() newN.length newN newN.substring(0, h) newN.substring newN 0 h System.out.println(newN) System.out.println System.out System System.out newN n = scan.nextLine() n scan.nextLine() scan.nextLine scan String[] args args public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String n = scan.nextLine();
	while (!n.equals("-")) {
	    int m = scan.nextInt();
	    scan.nextLine();
	    String newN = n;
	    for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    }
	    System.out.println(newN);
	    n = scan.nextLine();
	}
    }
} public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String n = scan.nextLine();
	while (!n.equals("-")) {
	    int m = scan.nextInt();
	    scan.nextLine();
	    String newN = n;
	    for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    }
	    System.out.println(newN);
	    n = scan.nextLine();
	}
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String n = scan.nextLine();
	while (!n.equals("-")) {
	    int m = scan.nextInt();
	    scan.nextLine();
	    String newN = n;
	    for (int i = 0; i < m; i++) {
		String hs = scan.nextLine();
		int h = Integer.valueOf(hs);
		newN = newN.substring(h, newN.length()) + newN.substring(0, h);
	    }
	    System.out.println(newN);
	    n = scan.nextLine();
	}
    }
}