/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);
	List<String> list = new ArrayList<String>();
	
	while (true) {
		String str = scan.next();
		if ("-".equals(str)) {
			break;
		}
		
		int m = scan.nextInt();
		int h[] = new int[m];

		for (int i = 0; i < m; i++) {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		}
		list.add(str);
	}
	
	for (String str : list) {
		System.out.println(str); 
	}
}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java class Main
{
public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);
	List<String> list = new ArrayList<String>();
	
	while (true) {
		String str = scan.next();
		if ("-".equals(str)) {
			break;
		}
		
		int m = scan.nextInt();
		int h[] = new int[m];

		for (int i = 0; i < m; i++) {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		}
		list.add(str);
	}
	
	for (String str : list) {
		System.out.println(str); 
	}
}
} Main public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);
	List<String> list = new ArrayList<String>();
	
	while (true) {
		String str = scan.next();
		if ("-".equals(str)) {
			break;
		}
		
		int m = scan.nextInt();
		int h[] = new int[m];

		for (int i = 0; i < m; i++) {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		}
		list.add(str);
	}
	
	for (String str : list) {
		System.out.println(str); 
	}
} main {
	Scanner scan = new Scanner(System.in);
	List<String> list = new ArrayList<String>();
	
	while (true) {
		String str = scan.next();
		if ("-".equals(str)) {
			break;
		}
		
		int m = scan.nextInt();
		int h[] = new int[m];

		for (int i = 0; i < m; i++) {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		}
		list.add(str);
	}
	
	for (String str : list) {
		System.out.println(str); 
	}
} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) List<String> list = new ArrayList<String>(); list new ArrayList<String>() while (true) {
		String str = scan.next();
		if ("-".equals(str)) {
			break;
		}
		
		int m = scan.nextInt();
		int h[] = new int[m];

		for (int i = 0; i < m; i++) {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		}
		list.add(str);
	} true {
		String str = scan.next();
		if ("-".equals(str)) {
			break;
		}
		
		int m = scan.nextInt();
		int h[] = new int[m];

		for (int i = 0; i < m; i++) {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		}
		list.add(str);
	} String str = scan.next(); str scan.next() scan.next scan if ("-".equals(str)) {
			break;
		} "-".equals(str) "-".equals "-" str {
			break;
		} break; int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan int h[] = new int[m]; h new int[m] m for (int i = 0; i < m; i++) {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		} {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		} h[i] = scan.nextInt() h[i] h i scan.nextInt() scan.nextInt scan str = str.substring(h[i]) + str.substring(0, h[i]) str str.substring(h[i]) + str.substring(0, h[i]) str.substring(h[i]) str.substring str h[i] h i str.substring(0, h[i]) str.substring str 0 h[i] h i list.add(str) list.add list str for (String str : list) {
		System.out.println(str); 
	} String str list {
		System.out.println(str); 
	} {
		System.out.println(str); 
	} System.out.println(str) System.out.println System.out System System.out str String[] args args
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);
	List<String> list = new ArrayList<String>();
	
	while (true) {
		String str = scan.next();
		if ("-".equals(str)) {
			break;
		}
		
		int m = scan.nextInt();
		int h[] = new int[m];

		for (int i = 0; i < m; i++) {
			h[i] = scan.nextInt();
			str = str.substring(h[i]) + str.substring(0, h[i]);						
		}
		list.add(str);
	}
	
	for (String str : list) {
		System.out.println(str); 
	}
}
}