import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        }
    } main {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        } true {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        } String cards = sc.nextLine(); cards sc.nextLine() sc.nextLine sc if(cards.equals("-")) {
        		break;
        	} cards.equals("-") cards.equals cards "-" {
        		break;
        	} break; int count = Integer.parseInt(sc.nextLine()); count Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            } int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            } {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            } int shuffleNum = Integer.parseInt(sc.nextLine()); shuffleNum Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum) cards cards.substring(shuffleNum) + cards.substring(0, shuffleNum) cards.substring(shuffleNum) cards.substring cards shuffleNum cards.substring(0, shuffleNum) cards.substring cards 0 shuffleNum System.out.println(cards) System.out.println System.out System System.out cards String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        }
    }
}
