import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		}
	}
} import java.io.*; io.* java import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		}
	}
} Main public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		}
	} main { 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		} true {
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		} String line = br.readLine(); line br.readLine() br.readLine br if (line.equals("-")) {break;} line.equals("-") line.equals line "-" {break;} break; int len = line.length(); len line.length() line.length line String word = line; word line String hst = br.readLine(); hst br.readLine() br.readLine br int m = Integer.parseInt(hst); m Integer.parseInt(hst) Integer.parseInt Integer hst for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			} int i = 0; int i = 0; i 0 i<m i m i++ i++ i {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			} {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			} String st = br.readLine(); st br.readLine() br.readLine br int h = Integer.parseInt(st); h Integer.parseInt(st) Integer.parseInt Integer st char[] c = word.toCharArray(); c word.toCharArray() word.toCharArray word word = "" word "" for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				} int j = h; int j = h; j h j < h+len j h+len h len j++ j++ j {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				} {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				} if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					} j < len j len {
						word += String.valueOf(c[j]);
					} word += String.valueOf(c[j]) word String.valueOf(c[j]) String.valueOf String c[j] c j {
						word += String.valueOf(c[j-len]);
					} word += String.valueOf(c[j-len]) word String.valueOf(c[j-len]) String.valueOf String c[j-len] c j-len j len System.out.println(word) System.out.println System.out System System.out word String[] args args public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		}
	}
} public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		}
	}
} Main
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		}
	}
}