import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = null;
		String mStr = null;
		int count = 0;
		Map<Integer, String> map = new HashMap<>();
		
		while (true) {
			try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} 
		}
		
		for (Map.Entry<Integer, String> entry: map.entrySet()) {
			System.out.println(entry.getValue());
		}

	}

}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = null;
		String mStr = null;
		int count = 0;
		Map<Integer, String> map = new HashMap<>();
		
		while (true) {
			try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} 
		}
		
		for (Map.Entry<Integer, String> entry: map.entrySet()) {
			System.out.println(entry.getValue());
		}

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = null;
		String mStr = null;
		int count = 0;
		Map<Integer, String> map = new HashMap<>();
		
		while (true) {
			try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} 
		}
		
		for (Map.Entry<Integer, String> entry: map.entrySet()) {
			System.out.println(entry.getValue());
		}

	} main {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = null;
		String mStr = null;
		int count = 0;
		Map<Integer, String> map = new HashMap<>();
		
		while (true) {
			try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} 
		}
		
		for (Map.Entry<Integer, String> entry: map.entrySet()) {
			System.out.println(entry.getValue());
		}

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String word = null; word null String mStr = null; mStr null int count = 0; count 0 Map<Integer, String> map = new HashMap<>(); map new HashMap<>() while (true) {
			try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} 
		} true {
			try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} 
		} try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} IOException e {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} word = br.readLine() word br.readLine() br.readLine br if ("-".equals(word)) {
					break;
				} "-".equals(word) "-".equals "-" word {
					break;
				} break; mStr = br.readLine() mStr br.readLine() br.readLine br int m = Integer.parseInt(mStr); m Integer.parseInt(mStr) Integer.parseInt Integer mStr for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				} {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				} int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br word = word.substring(h, word.length()) + word.substring(0, h) word word.substring(h, word.length()) + word.substring(0, h) word.substring(h, word.length()) word.substring word h word.length() word.length word word.substring(0, h) word.substring word 0 h map.put(count, word) map.put map count word count++ count for (Map.Entry<Integer, String> entry: map.entrySet()) {
			System.out.println(entry.getValue());
		} Map.Entry<Integer, String> entry map.entrySet() map.entrySet map {
			System.out.println(entry.getValue());
		} {
			System.out.println(entry.getValue());
		} System.out.println(entry.getValue()) System.out.println System.out System System.out entry.getValue() entry.getValue entry String[] args args public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = null;
		String mStr = null;
		int count = 0;
		Map<Integer, String> map = new HashMap<>();
		
		while (true) {
			try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} 
		}
		
		for (Map.Entry<Integer, String> entry: map.entrySet()) {
			System.out.println(entry.getValue());
		}

	}

} public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = null;
		String mStr = null;
		int count = 0;
		Map<Integer, String> map = new HashMap<>();
		
		while (true) {
			try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} 
		}
		
		for (Map.Entry<Integer, String> entry: map.entrySet()) {
			System.out.println(entry.getValue());
		}

	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = null;
		String mStr = null;
		int count = 0;
		Map<Integer, String> map = new HashMap<>();
		
		while (true) {
			try {
				word = br.readLine();

				if ("-".equals(word)) {
					break;
				}
				mStr = br.readLine();
				int m = Integer.parseInt(mStr);
				for (int i = 0; i < m; i++) {
					int h = Integer.parseInt(br.readLine());
					word = word.substring(h, word.length()) + word.substring(0, h);
				}
				map.put(count, word);
				count++;
				
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} 
		}
		
		for (Map.Entry<Integer, String> entry: map.entrySet()) {
			System.out.println(entry.getValue());
		}

	}

}

