import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			}
		}finally{
			if(scan!=null)scan.close();
		}
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			}
		}finally{
			if(scan!=null)scan.close();
		}
	}
} Main public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			}
		}finally{
			if(scan!=null)scan.close();
		}
	} main {
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			}
		}finally{
			if(scan!=null)scan.close();
		}
	} Scanner scan = null; scan null try{
			scan = new Scanner(System.in);
			while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			}
		}finally{
			if(scan!=null)scan.close();
		} {
			if(scan!=null)scan.close();
		} if(scan!=null)scan.close(); scan!=null scan null scan.close() scan.close scan {
			scan = new Scanner(System.in);
			while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			}
		} scan = new Scanner(System.in) scan new Scanner(System.in) while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			} true {
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			} String str = scan.next(); str scan.next() scan.next scan if(str.equals("-"))break; str.equals("-") str.equals str "-" break; int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 } {
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 } int data = scan.nextInt(); data scan.nextInt() scan.nextInt scan str = str.substring(data,str.length()) + str.substring(0,data) str str.substring(data,str.length()) + str.substring(0,data) str.substring(data,str.length()) str.substring str data str.length() str.length str str.substring(0,data) str.substring str 0 data System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			}
		}finally{
			if(scan!=null)scan.close();
		}
	}
} public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			}
		}finally{
			if(scan!=null)scan.close();
		}
	}
} Main
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			while(true){
				 String str = scan.next();
				 if(str.equals("-"))break;
				 int n = scan.nextInt();
				 for(int i = 0 ;i < n;i++){
					 int data = scan.nextInt();
					 str = str.substring(data,str.length()) + str.substring(0,data);
				 }
				 System.out.println(str);
			}
		}finally{
			if(scan!=null)scan.close();
		}
	}
}