import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String str;
    	String left;
    	String right;
    	String end = "-";
    	int shuffle;
    	int m;
    	
    	for(;;){
    		str = scan.next();
    		if(str.equals(end)) {
    			break;
    		}
    		m = scan.nextInt();
    		for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		}
    		System.out.println(str);
    	}
     }
} import java.util.Scanner; Scanner java.util class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String str;
    	String left;
    	String right;
    	String end = "-";
    	int shuffle;
    	int m;
    	
    	for(;;){
    		str = scan.next();
    		if(str.equals(end)) {
    			break;
    		}
    		m = scan.nextInt();
    		for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		}
    		System.out.println(str);
    	}
     }
} Main public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String str;
    	String left;
    	String right;
    	String end = "-";
    	int shuffle;
    	int m;
    	
    	for(;;){
    		str = scan.next();
    		if(str.equals(end)) {
    			break;
    		}
    		m = scan.nextInt();
    		for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		}
    		System.out.println(str);
    	}
     } main {
    	Scanner scan = new Scanner(System.in);
    	String str;
    	String left;
    	String right;
    	String end = "-";
    	int shuffle;
    	int m;
    	
    	for(;;){
    		str = scan.next();
    		if(str.equals(end)) {
    			break;
    		}
    		m = scan.nextInt();
    		for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		}
    		System.out.println(str);
    	}
     } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str; str String left; left String right; right String end = "-"; end "-" int shuffle; shuffle int m; m for(;;){
    		str = scan.next();
    		if(str.equals(end)) {
    			break;
    		}
    		m = scan.nextInt();
    		for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		}
    		System.out.println(str);
    	} ; {
    		str = scan.next();
    		if(str.equals(end)) {
    			break;
    		}
    		m = scan.nextInt();
    		for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		}
    		System.out.println(str);
    	} {
    		str = scan.next();
    		if(str.equals(end)) {
    			break;
    		}
    		m = scan.nextInt();
    		for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		}
    		System.out.println(str);
    	} str = scan.next() str scan.next() scan.next scan if(str.equals(end)) {
    			break;
    		} str.equals(end) str.equals str end {
    			break;
    		} break; m = scan.nextInt() m scan.nextInt() scan.nextInt scan for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		} {
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		} shuffle = scan.nextInt() shuffle scan.nextInt() scan.nextInt scan left = str.substring(0, shuffle) left str.substring(0, shuffle) str.substring str 0 shuffle right = str.substring(shuffle) right str.substring(shuffle) str.substring str shuffle str = right + left str right + left right left System.out.println(str) System.out.println System.out System System.out str String[] args args
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String str;
    	String left;
    	String right;
    	String end = "-";
    	int shuffle;
    	int m;
    	
    	for(;;){
    		str = scan.next();
    		if(str.equals(end)) {
    			break;
    		}
    		m = scan.nextInt();
    		for(int i = 0; i < m; i++){
    			shuffle = scan.nextInt();
    			left = str.substring(0, shuffle);
    			right = str.substring(shuffle);
    			str = right + left;
    		}
    		System.out.println(str);
    	}
     }
}