import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String mot = "";
		String fro = "";
		String bac = ""; 
		String str;
		String shu = "";
		
		
		
		int count = 0;
		int i = 0;
		int h = 0;
		
		
		while(true){
			
			//System.out.println("word please");
			mot = as.next();
			//System.out.println(mot+"::");
			
			if(mot.equals("-")){
				
				break;
				
			}
			
			shu = mot;
			//System.out.println("number please");
			count = as.nextInt();
			
			for(i=0;i<count;i++){
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			}
			
			str = shu;
			System.out.println(str);
			
		}

	}

} import java.util.Scanner; Scanner java.util class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String mot = "";
		String fro = "";
		String bac = ""; 
		String str;
		String shu = "";
		
		
		
		int count = 0;
		int i = 0;
		int h = 0;
		
		
		while(true){
			
			//System.out.println("word please");
			mot = as.next();
			//System.out.println(mot+"::");
			
			if(mot.equals("-")){
				
				break;
				
			}
			
			shu = mot;
			//System.out.println("number please");
			count = as.nextInt();
			
			for(i=0;i<count;i++){
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			}
			
			str = shu;
			System.out.println(str);
			
		}

	}

} Main /**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String mot = "";
		String fro = "";
		String bac = ""; 
		String str;
		String shu = "";
		
		
		
		int count = 0;
		int i = 0;
		int h = 0;
		
		
		while(true){
			
			//System.out.println("word please");
			mot = as.next();
			//System.out.println(mot+"::");
			
			if(mot.equals("-")){
				
				break;
				
			}
			
			shu = mot;
			//System.out.println("number please");
			count = as.nextInt();
			
			for(i=0;i<count;i++){
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			}
			
			str = shu;
			System.out.println(str);
			
		}

	} main {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String mot = "";
		String fro = "";
		String bac = ""; 
		String str;
		String shu = "";
		
		
		
		int count = 0;
		int i = 0;
		int h = 0;
		
		
		while(true){
			
			//System.out.println("word please");
			mot = as.next();
			//System.out.println(mot+"::");
			
			if(mot.equals("-")){
				
				break;
				
			}
			
			shu = mot;
			//System.out.println("number please");
			count = as.nextInt();
			
			for(i=0;i<count;i++){
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			}
			
			str = shu;
			System.out.println(str);
			
		}

	} Scanner as = new Scanner(System.in); as new Scanner(System.in) String mot = ""; mot "" String fro = ""; fro "" String bac = ""; bac "" String str; str String shu = ""; shu "" int count = 0; count 0 int i = 0; i 0 int h = 0; h 0 while(true){
			
			//System.out.println("word please");
			mot = as.next();
			//System.out.println(mot+"::");
			
			if(mot.equals("-")){
				
				break;
				
			}
			
			shu = mot;
			//System.out.println("number please");
			count = as.nextInt();
			
			for(i=0;i<count;i++){
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			}
			
			str = shu;
			System.out.println(str);
			
		} true {
			
			//System.out.println("word please");
			mot = as.next();
			//System.out.println(mot+"::");
			
			if(mot.equals("-")){
				
				break;
				
			}
			
			shu = mot;
			//System.out.println("number please");
			count = as.nextInt();
			
			for(i=0;i<count;i++){
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			}
			
			str = shu;
			System.out.println(str);
			
		} mot = as.next() mot as.next() as.next as if(mot.equals("-")){
				
				break;
				
			} mot.equals("-") mot.equals mot "-" {
				
				break;
				
			} break; shu = mot shu mot count = as.nextInt() count as.nextInt() as.nextInt as for(i=0;i<count;i++){
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			} i=0; i=0 i 0 i<count i count i++ i++ i {
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			} {
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			} h = as.nextInt() h as.nextInt() as.nextInt as fro = shu.substring(0,h) fro shu.substring(0,h) shu.substring shu 0 h bac = shu.substring(h) bac shu.substring(h) shu.substring shu h shu = bac + fro shu bac + fro bac fro str = shu str shu System.out.println(str) System.out.println System.out System System.out str String[] args args
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String mot = "";
		String fro = "";
		String bac = ""; 
		String str;
		String shu = "";
		
		
		
		int count = 0;
		int i = 0;
		int h = 0;
		
		
		while(true){
			
			//System.out.println("word please");
			mot = as.next();
			//System.out.println(mot+"::");
			
			if(mot.equals("-")){
				
				break;
				
			}
			
			shu = mot;
			//System.out.println("number please");
			count = as.nextInt();
			
			for(i=0;i<count;i++){
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			}
			
			str = shu;
			System.out.println(str);
			
		}

	}

}