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

	public static void main(String[] args) throws IOException
	{
		int m;
		String strSub;

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

        while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        }
	}
} 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) throws IOException
	{
		int m;
		String strSub;

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

        while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        }
	}
} Main public static void main(String[] args) throws IOException
	{
		int m;
		String strSub;

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

        while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        }
	} main {
		int m;
		String strSub;

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

        while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        }
	} int m; m String strSub; strSub BufferedReader br = new BufferedReader(new InputStreamReader(System.in) ); br new BufferedReader(new InputStreamReader(System.in) ) while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        } true {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        } String str = br.readLine(); str br.readLine() br.readLine br if(str.equals("-") ) break; str.equals("-") str.equals str "-" break; String strM = br.readLine(); strM br.readLine() br.readLine br m = Integer.parseInt(strM) m Integer.parseInt(strM) Integer.parseInt Integer strM int[] h = new int[m]; h new int[m] m for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            } {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            } String strH = br.readLine(); strH br.readLine() br.readLine br h[i] = Integer.parseInt(strH) h[i] h i Integer.parseInt(strH) Integer.parseInt Integer strH strSub = str.substring(0, h[i]) strSub str.substring(0, h[i]) str.substring str 0 h[i] h i str = str + strSub str str + strSub str strSub strSub = str.substring(h[i]) strSub str.substring(h[i]) str.substring str h[i] h i str = null str null str = strSub str strSub System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main{

	public static void main(String[] args) throws IOException
	{
		int m;
		String strSub;

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

        while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        }
	}
} public class Main{

	public static void main(String[] args) throws IOException
	{
		int m;
		String strSub;

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

        while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        }
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{

	public static void main(String[] args) throws IOException
	{
		int m;
		String strSub;

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

        while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str = str + strSub;
        		
        		strSub = str.substring(h[i]);
        		str = null;//init string
        		str = strSub;
        		//System.out.println(strSub);
            }
            System.out.println(str);
            
        }
	}
}