
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String cards;
			while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

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

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String cards;
			while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
} Main public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String cards;
			while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String cards;
			while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {

			String cards;
			while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		} if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			} br != null br null {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			} try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				} IOException e {
					e.printStackTrace();
				} e.printStackTrace() e.printStackTrace e {
					br.close();
				} br.close() br.close br {

			String cards;
			while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			}
		} String cards; cards while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			} true {
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			} cards = br.readLine() cards br.readLine() br.readLine br if(cards == null || cards.equals("-") ){
					break;
				} cards == null || cards.equals("-") cards == null cards null cards.equals("-") cards.equals cards "-" {
					break;
				} break; StringBuilder sb = new StringBuilder(cards); sb new StringBuilder(cards) int m = Integer.parseInt(br.readLine()); m Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				} int i=0; int i=0; i 0 i<m i m i++ i++ i {
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				} {
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				} int h = Integer.parseInt(br.readLine()); h Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br sb.append(sb.substring(0,h)) sb.append sb sb.substring(0,h) sb.substring sb 0 h sb.delete(0, h) sb.delete sb 0 h System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb String[] args args public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String cards;
			while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
} public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String cards;
			while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String cards;
			while(true){
				cards = br.readLine();
				if(cards == null || cards.equals("-") ){
					break;
				}
				StringBuilder sb = new StringBuilder(cards);

				int m = Integer.parseInt(br.readLine());

				for(int i=0;i<m;i++){
					int h = Integer.parseInt(br.readLine());

					sb.append(sb.substring(0,h));
					sb.delete(0, h);

				}
				System.out.println(sb.toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
}