import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();	//?????£?????????????????????????????°
        while( !(str.equals("-")) ) {
			String repStr = br.readLine();	//??°??????????????°
			int rep = Integer.parseInt(repStr);
			for(int i = 0 ; i < rep ; i++ ) {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			}
			System.out.println(str);	//???????????????
			str = br.readLine();
		}
	}
} import java.io.IOException; IOException java.io import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();	//?????£?????????????????????????????°
        while( !(str.equals("-")) ) {
			String repStr = br.readLine();	//??°??????????????°
			int rep = Integer.parseInt(repStr);
			for(int i = 0 ; i < rep ; i++ ) {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			}
			System.out.println(str);	//???????????????
			str = br.readLine();
		}
	}
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();	//?????£?????????????????????????????°
        while( !(str.equals("-")) ) {
			String repStr = br.readLine();	//??°??????????????°
			int rep = Integer.parseInt(repStr);
			for(int i = 0 ; i < rep ; i++ ) {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			}
			System.out.println(str);	//???????????????
			str = br.readLine();
		}
	} main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();	//?????£?????????????????????????????°
        while( !(str.equals("-")) ) {
			String repStr = br.readLine();	//??°??????????????°
			int rep = Integer.parseInt(repStr);
			for(int i = 0 ; i < rep ; i++ ) {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			}
			System.out.println(str);	//???????????????
			str = br.readLine();
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br while( !(str.equals("-")) ) {
			String repStr = br.readLine();	//??°??????????????°
			int rep = Integer.parseInt(repStr);
			for(int i = 0 ; i < rep ; i++ ) {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			}
			System.out.println(str);	//???????????????
			str = br.readLine();
		} !(str.equals("-")) (str.equals("-")) str.equals str "-" {
			String repStr = br.readLine();	//??°??????????????°
			int rep = Integer.parseInt(repStr);
			for(int i = 0 ; i < rep ; i++ ) {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			}
			System.out.println(str);	//???????????????
			str = br.readLine();
		} String repStr = br.readLine(); repStr br.readLine() br.readLine br int rep = Integer.parseInt(repStr); rep Integer.parseInt(repStr) Integer.parseInt Integer repStr for(int i = 0 ; i < rep ; i++ ) {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			} int i = 0 ; int i = 0 ; i 0 i < rep i rep i++ i++ i {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			} {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			} String posStr = br.readLine(); posStr br.readLine() br.readLine br int pos = Integer.parseInt(posStr); pos Integer.parseInt(posStr) Integer.parseInt Integer posStr String left = str.substring(0, pos); left str.substring(0, pos) str.substring str 0 pos String right = str.substring(pos); right str.substring(pos) str.substring str pos str = right + left str right + left right left System.out.println(str) System.out.println System.out System System.out str str = br.readLine() str br.readLine() br.readLine br String[] args args
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();	//?????£?????????????????????????????°
        while( !(str.equals("-")) ) {
			String repStr = br.readLine();	//??°??????????????°
			int rep = Integer.parseInt(repStr);
			for(int i = 0 ; i < rep ; i++ ) {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			}
			System.out.println(str);	//???????????????
			str = br.readLine();
		}
	}
}