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

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        }
	}

} 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{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        }
	}

} Main public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        }
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        }
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) while (true)
        {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        } true {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        } String mojiretu = br.readLine(); mojiretu br.readLine() br.readLine br if (mojiretu.equals("-"))
        		break; mojiretu.equals("-") mojiretu.equals mojiretu "-" break; int kaisu = Integer.parseInt(br.readLine()); kaisu Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	} int i = 0; int i = 0; i 0 i < kaisu i kaisu i++ i++ i {
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	} {
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	} int shaffle = Integer.parseInt(br.readLine()); shaffle Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br String cut = mojiretu.substring(0, shaffle); cut mojiretu.substring(0, shaffle) mojiretu.substring mojiretu 0 shaffle String nokori = mojiretu.substring(shaffle); nokori mojiretu.substring(shaffle) mojiretu.substring mojiretu shaffle mojiretu = nokori + cut mojiretu nokori + cut nokori cut System.out.println(mojiretu) System.out.println System.out System System.out mojiretu String[] args args public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        }
	}

} public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        }
	}

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

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        }
	}

}