import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String key = br.readLine();
			if(key.equals("-")) break;
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			}
			System.out.println(key);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String key = br.readLine();
			if(key.equals("-")) break;
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			}
			System.out.println(key);
		}
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String key = br.readLine();
			if(key.equals("-")) break;
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			}
			System.out.println(key);
		}
	} main {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String key = br.readLine();
			if(key.equals("-")) break;
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			}
			System.out.println(key);
		}
	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String key = br.readLine();
			if(key.equals("-")) break;
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			}
			System.out.println(key);
		} true {
			String key = br.readLine();
			if(key.equals("-")) break;
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			}
			System.out.println(key);
		} String key = br.readLine(); key br.readLine() br.readLine br if(key.equals("-")) break; key.equals("-") key.equals key "-" break; int n=Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			} int i=0; int i=0; i 0 i<n i n i++ i++ i {
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			} {
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			} int ch=Integer.parseInt(br.readLine()); ch Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br String tmpstr=key.substring(0,ch); tmpstr key.substring(0,ch) key.substring key 0 ch key=key.substring(ch, key.length())+tmpstr key key.substring(ch, key.length())+tmpstr key.substring(ch, key.length()) key.substring key ch key.length() key.length key tmpstr System.out.println(key) System.out.println System.out System System.out key String[] args args public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String key = br.readLine();
			if(key.equals("-")) break;
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			}
			System.out.println(key);
		}
	}
} public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String key = br.readLine();
			if(key.equals("-")) break;
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			}
			System.out.println(key);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String key = br.readLine();
			if(key.equals("-")) break;
			int n=Integer.parseInt(br.readLine());
			for(int i=0;i<n;i++){
				int ch=Integer.parseInt(br.readLine());
				String tmpstr=key.substring(0,ch);
				key=key.substring(ch, key.length())+tmpstr;
			}
			System.out.println(key);
		}
	}
}