import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        List<String> list = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true) {
            String line = br.readLine();
            if(line.equals("-")){
                list.add(sb.toString());
                break;
            }
            if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            }
            int sub = Integer.parseInt(line);
            String tmp = sb.substring(0,sub);
            sb = sb.delete(0,sub);
            sb.append(tmp);
        }
        list.remove(0);
        for(String s:list) 
            System.out.println(s);
    }
    static boolean isNumber(String val) {
    	try {
    		Integer.parseInt(val);
    		return true;
    	} catch (NumberFormatException nfex) {
    		return false;
    	}
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        List<String> list = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true) {
            String line = br.readLine();
            if(line.equals("-")){
                list.add(sb.toString());
                break;
            }
            if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            }
            int sub = Integer.parseInt(line);
            String tmp = sb.substring(0,sub);
            sb = sb.delete(0,sub);
            sb.append(tmp);
        }
        list.remove(0);
        for(String s:list) 
            System.out.println(s);
    }
    static boolean isNumber(String val) {
    	try {
    		Integer.parseInt(val);
    		return true;
    	} catch (NumberFormatException nfex) {
    		return false;
    	}
    }
} Main public static void main(String[] args) throws Exception {
        List<String> list = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true) {
            String line = br.readLine();
            if(line.equals("-")){
                list.add(sb.toString());
                break;
            }
            if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            }
            int sub = Integer.parseInt(line);
            String tmp = sb.substring(0,sub);
            sb = sb.delete(0,sub);
            sb.append(tmp);
        }
        list.remove(0);
        for(String s:list) 
            System.out.println(s);
    } main {
        List<String> list = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true) {
            String line = br.readLine();
            if(line.equals("-")){
                list.add(sb.toString());
                break;
            }
            if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            }
            int sub = Integer.parseInt(line);
            String tmp = sb.substring(0,sub);
            sb = sb.delete(0,sub);
            sb.append(tmp);
        }
        list.remove(0);
        for(String s:list) 
            System.out.println(s);
    } List<String> list = new ArrayList<String>(); list new ArrayList<String>() BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true) {
            String line = br.readLine();
            if(line.equals("-")){
                list.add(sb.toString());
                break;
            }
            if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            }
            int sub = Integer.parseInt(line);
            String tmp = sb.substring(0,sub);
            sb = sb.delete(0,sub);
            sb.append(tmp);
        } true {
            String line = br.readLine();
            if(line.equals("-")){
                list.add(sb.toString());
                break;
            }
            if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            }
            int sub = Integer.parseInt(line);
            String tmp = sb.substring(0,sub);
            sb = sb.delete(0,sub);
            sb.append(tmp);
        } String line = br.readLine(); line br.readLine() br.readLine br if(line.equals("-")){
                list.add(sb.toString());
                break;
            } line.equals("-") line.equals line "-" {
                list.add(sb.toString());
                break;
            } list.add(sb.toString()) list.add list sb.toString() sb.toString sb break; if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            } !isNumber(line) isNumber(line) isNumber line {
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            } list.add(sb.toString()) list.add list sb.toString() sb.toString sb sb = new StringBuilder(line) sb new StringBuilder(line) String foo = br.readLine(); foo br.readLine() br.readLine br continue; int sub = Integer.parseInt(line); sub Integer.parseInt(line) Integer.parseInt Integer line String tmp = sb.substring(0,sub); tmp sb.substring(0,sub) sb.substring sb 0 sub sb = sb.delete(0,sub) sb sb.delete(0,sub) sb.delete sb 0 sub sb.append(tmp) sb.append sb tmp list.remove(0) list.remove list 0 for(String s:list) 
            System.out.println(s); String s list System.out.println(s); System.out.println(s) System.out.println System.out System System.out s String[] args args static boolean isNumber(String val) {
    	try {
    		Integer.parseInt(val);
    		return true;
    	} catch (NumberFormatException nfex) {
    		return false;
    	}
    } isNumber {
    	try {
    		Integer.parseInt(val);
    		return true;
    	} catch (NumberFormatException nfex) {
    		return false;
    	}
    } try {
    		Integer.parseInt(val);
    		return true;
    	} catch (NumberFormatException nfex) {
    		return false;
    	} catch (NumberFormatException nfex) {
    		return false;
    	} NumberFormatException nfex {
    		return false;
    	} return false; false {
    		Integer.parseInt(val);
    		return true;
    	} Integer.parseInt(val) Integer.parseInt Integer val return true; true String val val public class Main {
    public static void main(String[] args) throws Exception {
        List<String> list = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true) {
            String line = br.readLine();
            if(line.equals("-")){
                list.add(sb.toString());
                break;
            }
            if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            }
            int sub = Integer.parseInt(line);
            String tmp = sb.substring(0,sub);
            sb = sb.delete(0,sub);
            sb.append(tmp);
        }
        list.remove(0);
        for(String s:list) 
            System.out.println(s);
    }
    static boolean isNumber(String val) {
    	try {
    		Integer.parseInt(val);
    		return true;
    	} catch (NumberFormatException nfex) {
    		return false;
    	}
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        List<String> list = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true) {
            String line = br.readLine();
            if(line.equals("-")){
                list.add(sb.toString());
                break;
            }
            if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            }
            int sub = Integer.parseInt(line);
            String tmp = sb.substring(0,sub);
            sb = sb.delete(0,sub);
            sb.append(tmp);
        }
        list.remove(0);
        for(String s:list) 
            System.out.println(s);
    }
    static boolean isNumber(String val) {
    	try {
    		Integer.parseInt(val);
    		return true;
    	} catch (NumberFormatException nfex) {
    		return false;
    	}
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        List<String> list = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true) {
            String line = br.readLine();
            if(line.equals("-")){
                list.add(sb.toString());
                break;
            }
            if(!isNumber(line)){
                list.add(sb.toString());
                sb = new StringBuilder(line);
                String foo = br.readLine();//消化
                continue;
            }
            int sub = Integer.parseInt(line);
            String tmp = sb.substring(0,sub);
            sb = sb.delete(0,sub);
            sb.append(tmp);
        }
        list.remove(0);
        for(String s:list) 
            System.out.println(s);
    }
    static boolean isNumber(String val) {
    	try {
    		Integer.parseInt(val);
    		return true;
    	} catch (NumberFormatException nfex) {
    		return false;
    	}
    }
}