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

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        }
    }


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

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        }
    }


} Main public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        }
    } main {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        }
    } try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        } {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String line line result=""; result "" boolean first=true; first true int sum=0 sum 0 n=0 n 0 i=0; i 0 while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            } if(line.equals("-"))break; line.equals("-") line.equals line "-" break; if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	} first {
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	} result=line result line n=Integer.parseInt(br.readLine()) n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br i=0 i 0 first=false first false {
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	} int a=Integer.parseInt(line); a Integer.parseInt(line) Integer.parseInt Integer line result=result.substring(a,result.length())+result.substring(0,a) result result.substring(a,result.length())+result.substring(0,a) result.substring(a,result.length()) result.substring result a result.length() result.length result result.substring(0,a) result.substring result 0 a i++ i if(i==n){
            			System.out.println(result);
            			first=true;
            		} i==n i n {
            			System.out.println(result);
            			first=true;
            		} System.out.println(result) System.out.println System.out System System.out result first=true first true String[] args args public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        }
    }


} public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        }
    }


} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        }
    }


}