import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args) {
		sc= new Scanner(System.in);
		int i=0,j=0;
		int count=0;
		int m[]=new int[300];
		int h[][]=new int[10][300];
		String card[] =new String[300];
		for(;;) {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		}
		
		
		for(i=0;i<count;i++) {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		}	
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static Scanner sc;
	public static void main(String[] args) {
		sc= new Scanner(System.in);
		int i=0,j=0;
		int count=0;
		int m[]=new int[300];
		int h[][]=new int[10][300];
		String card[] =new String[300];
		for(;;) {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		}
		
		
		for(i=0;i<count;i++) {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		}	
	}
} Main public static Scanner sc; sc public static void main(String[] args) {
		sc= new Scanner(System.in);
		int i=0,j=0;
		int count=0;
		int m[]=new int[300];
		int h[][]=new int[10][300];
		String card[] =new String[300];
		for(;;) {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		}
		
		
		for(i=0;i<count;i++) {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		}	
	} main {
		sc= new Scanner(System.in);
		int i=0,j=0;
		int count=0;
		int m[]=new int[300];
		int h[][]=new int[10][300];
		String card[] =new String[300];
		for(;;) {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		}
		
		
		for(i=0;i<count;i++) {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		}	
	} sc= new Scanner(System.in) sc new Scanner(System.in) int i=0 i 0 j=0; j 0 int count=0; count 0 int m[]=new int[300]; m new int[300] 300 int h[][]=new int[10][300]; h new int[10][300] 10 300 String card[] =new String[300]; card new String[300] 300 for(;;) {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		} ; {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		} {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		} card[i]=sc.next() card[i] card i sc.next() sc.next sc if(card[i].equals("-")) {
				break;
			} card[i].equals("-") card[i].equals card[i] card i "-" {
				break;
			} break; m[i]=sc.nextInt() m[i] m i sc.nextInt() sc.nextInt sc for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			} j=0; j=0 j 0 j<m[i] j m[i] m i j++ j++ j {
				h[i][j]=sc.nextInt();
			} {
				h[i][j]=sc.nextInt();
			} h[i][j]=sc.nextInt() h[i][j] h[i] h i j sc.nextInt() sc.nextInt sc i++ i count++ count for(i=0;i<count;i++) {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		} i=0; i=0 i 0 i<count i count i++ i++ i {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		} {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		} for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			} j=0; j=0 j 0 j<m[i] j m[i] m i j++ j++ j {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			} {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			} String s1 = card[i].substring(0,h[i][j]); s1 card[i].substring(0,h[i][j]) card[i].substring card[i] card i 0 h[i][j] h[i] h i j String s2 = card[i].substring(h[i][j]); s2 card[i].substring(h[i][j]) card[i].substring card[i] card i h[i][j] h[i] h i j card[i]=s2+s1 card[i] card i s2+s1 s2 s1 System.out.println(card[i]) System.out.println System.out System System.out card[i] card i String[] args args public class Main {
	public static Scanner sc;
	public static void main(String[] args) {
		sc= new Scanner(System.in);
		int i=0,j=0;
		int count=0;
		int m[]=new int[300];
		int h[][]=new int[10][300];
		String card[] =new String[300];
		for(;;) {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		}
		
		
		for(i=0;i<count;i++) {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		}	
	}
} public class Main {
	public static Scanner sc;
	public static void main(String[] args) {
		sc= new Scanner(System.in);
		int i=0,j=0;
		int count=0;
		int m[]=new int[300];
		int h[][]=new int[10][300];
		String card[] =new String[300];
		for(;;) {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		}
		
		
		for(i=0;i<count;i++) {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		}	
	}
} Main
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args) {
		sc= new Scanner(System.in);
		int i=0,j=0;
		int count=0;
		int m[]=new int[300];
		int h[][]=new int[10][300];
		String card[] =new String[300];
		for(;;) {
			card[i]=sc.next();
			if(card[i].equals("-")) {
				break;
			}
			m[i]=sc.nextInt();
			for(j=0;j<m[i];j++) {
				h[i][j]=sc.nextInt();
			}
			i++;
			count++;
		}
		
		
		for(i=0;i<count;i++) {
			for(j=0;j<m[i];j++) {
			String s1 = card[i].substring(0,h[i][j]);
			String s2 = card[i].substring(h[i][j]);
			card[i]=s2+s1;
			}
			System.out.println(card[i]);
		}	
	}
}

