import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        }
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        }
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(sc.hasNextLine()) {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        } sc.hasNextLine() sc.hasNextLine sc {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        } String num=sc.nextLine(); num sc.nextLine() sc.nextLine sc if(num.equals("-")) {
        	break;
        } num.equals("-") num.equals num "-" {
        	break;
        } break; int m=Integer.parseInt(sc.nextLine()); m Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        } int i=0; int i=0; i 0 i<m i m i++ i++ i {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        } {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        } int h=Integer.parseInt(sc.nextLine()); h Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc String head = num.substring(0,h); head num.substring(0,h) num.substring num 0 h String tail = num.substring(h); tail num.substring(h) num.substring num h num = tail + head num tail + head tail head System.out.printf("%s\n", num) System.out.printf System.out System System.out "%s\n" num sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        }
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        }
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()) {
        String num=sc.nextLine();
        if(num.equals("-")) {
        	break;
        }
        int m=Integer.parseInt(sc.nextLine());
        for(int i=0;i<m;i++) {
        	int h=Integer.parseInt(sc.nextLine());
        	String head = num.substring(0,h);
        	String tail = num.substring(h);
        	num = tail + head;
        }
        System.out.printf("%s\n", num);
        }
        sc.close();
    }
}
