import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


class Main{
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		while(true){
		String x=br.readLine();
		if(x.equals("-"))break;
		int y=Integer.parseInt(br.readLine());
		int z=0;
		String str;
		StringBuilder stb=new StringBuilder(x);
		
		for(int i=0;i<y;i++){
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		}System.out.println(stb);
		
		}
		}
		
		} import java.io.BufferedReader; BufferedReader java.io import java.io.FileReader; FileReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		while(true){
		String x=br.readLine();
		if(x.equals("-"))break;
		int y=Integer.parseInt(br.readLine());
		int z=0;
		String str;
		StringBuilder stb=new StringBuilder(x);
		
		for(int i=0;i<y;i++){
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		}System.out.println(stb);
		
		}
		}
		
		} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		while(true){
		String x=br.readLine();
		if(x.equals("-"))break;
		int y=Integer.parseInt(br.readLine());
		int z=0;
		String str;
		StringBuilder stb=new StringBuilder(x);
		
		for(int i=0;i<y;i++){
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		}System.out.println(stb);
		
		}
		} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		while(true){
		String x=br.readLine();
		if(x.equals("-"))break;
		int y=Integer.parseInt(br.readLine());
		int z=0;
		String str;
		StringBuilder stb=new StringBuilder(x);
		
		for(int i=0;i<y;i++){
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		}System.out.println(stb);
		
		}
		} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
		String x=br.readLine();
		if(x.equals("-"))break;
		int y=Integer.parseInt(br.readLine());
		int z=0;
		String str;
		StringBuilder stb=new StringBuilder(x);
		
		for(int i=0;i<y;i++){
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		}System.out.println(stb);
		
		} true {
		String x=br.readLine();
		if(x.equals("-"))break;
		int y=Integer.parseInt(br.readLine());
		int z=0;
		String str;
		StringBuilder stb=new StringBuilder(x);
		
		for(int i=0;i<y;i++){
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		}System.out.println(stb);
		
		} String x=br.readLine(); x br.readLine() br.readLine br if(x.equals("-"))break; x.equals("-") x.equals x "-" break; int y=Integer.parseInt(br.readLine()); y Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int z=0; z 0 String str; str StringBuilder stb=new StringBuilder(x); stb new StringBuilder(x) for(int i=0;i<y;i++){
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		} int i=0; int i=0; i 0 i<y i y i++ i++ i {
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		} {
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		} z=Integer.parseInt(br.readLine()) z Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br stb=stb.append(stb.substring(0,z)) stb stb.append(stb.substring(0,z)) stb.append stb stb.substring(0,z) stb.substring stb 0 z stb=stb.delete(0, z) stb stb.delete(0, z) stb.delete stb 0 z System.out.println(stb) System.out.println System.out System System.out stb String[] args args
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


class Main{
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		while(true){
		String x=br.readLine();
		if(x.equals("-"))break;
		int y=Integer.parseInt(br.readLine());
		int z=0;
		String str;
		StringBuilder stb=new StringBuilder(x);
		
		for(int i=0;i<y;i++){
			z=Integer.parseInt(br.readLine());
			stb=stb.append(stb.substring(0,z));
			stb=stb.delete(0, z);
		}System.out.println(stb);
		
		}
		}
		
		}