import java.awt.print.Printable;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strs[] = new String[100];
        int count2=0;
        while(true){
            String str = sc.next();
            //System.out.println("Str is "+str);
            if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                }
            int num = sc.nextInt();
            //System.out.println("Num is "+num);
            for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            }
            strs[count2]=str;
            count2++;
        }  
    }   
} import java.awt.print.Printable; Printable java.awt.print import java.util.Scanner; Scanner java.util import javax.sound.midi.SysexMessage; SysexMessage javax.sound.midi public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strs[] = new String[100];
        int count2=0;
        while(true){
            String str = sc.next();
            //System.out.println("Str is "+str);
            if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                }
            int num = sc.nextInt();
            //System.out.println("Num is "+num);
            for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            }
            strs[count2]=str;
            count2++;
        }  
    }   
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strs[] = new String[100];
        int count2=0;
        while(true){
            String str = sc.next();
            //System.out.println("Str is "+str);
            if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                }
            int num = sc.nextInt();
            //System.out.println("Num is "+num);
            for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            }
            strs[count2]=str;
            count2++;
        }  
    } main {
        Scanner sc = new Scanner(System.in);
        String strs[] = new String[100];
        int count2=0;
        while(true){
            String str = sc.next();
            //System.out.println("Str is "+str);
            if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                }
            int num = sc.nextInt();
            //System.out.println("Num is "+num);
            for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            }
            strs[count2]=str;
            count2++;
        }  
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String strs[] = new String[100]; strs new String[100] 100 int count2=0; count2 0 while(true){
            String str = sc.next();
            //System.out.println("Str is "+str);
            if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                }
            int num = sc.nextInt();
            //System.out.println("Num is "+num);
            for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            }
            strs[count2]=str;
            count2++;
        } true {
            String str = sc.next();
            //System.out.println("Str is "+str);
            if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                }
            int num = sc.nextInt();
            //System.out.println("Num is "+num);
            for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            }
            strs[count2]=str;
            count2++;
        } String str = sc.next(); str sc.next() sc.next sc if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                } str.equals("-") str.equals str "-" {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                } for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    } int j=0; int j=0; j 0 j<count2 j count2 j++ j++ j {
                        System.out.println(strs[j]);
                    } {
                        System.out.println(strs[j]);
                    } System.out.println(strs[j]) System.out.println System.out System System.out strs[j] strs j sc.close() sc.close sc break; int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            } int i=0; int i=0; i 0 i<num i num i++ i++ i {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            } {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            } int count=sc.nextInt(); count sc.nextInt() sc.nextInt sc String str1=str.substring(0,count); str1 str.substring(0,count) str.substring str 0 count String str2=str.substring(count,str.length()); str2 str.substring(count,str.length()) str.substring str count str.length() str.length str str = str2 + str1 str str2 + str1 str2 str1 strs[count2]=str strs[count2] strs count2 str count2++ count2 String[] args args public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strs[] = new String[100];
        int count2=0;
        while(true){
            String str = sc.next();
            //System.out.println("Str is "+str);
            if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                }
            int num = sc.nextInt();
            //System.out.println("Num is "+num);
            for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            }
            strs[count2]=str;
            count2++;
        }  
    }   
} public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strs[] = new String[100];
        int count2=0;
        while(true){
            String str = sc.next();
            //System.out.println("Str is "+str);
            if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                }
            int num = sc.nextInt();
            //System.out.println("Num is "+num);
            for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            }
            strs[count2]=str;
            count2++;
        }  
    }   
} Main
import java.awt.print.Printable;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strs[] = new String[100];
        int count2=0;
        while(true){
            String str = sc.next();
            //System.out.println("Str is "+str);
            if(str.equals("-"))
                {
                    for(int j=0;j<count2;j++){
                        System.out.println(strs[j]);
                    }
                    sc.close();
                    break;
                }
            int num = sc.nextInt();
            //System.out.println("Num is "+num);
            for(int i=0;i<num;i++)
            {
                int count=sc.nextInt();
                String str1=str.substring(0,count);
                String str2=str.substring(count,str.length());
                str = str2 + str1;
                //System.out.println("I is "+i+" str is "+str);
            }
            strs[count2]=str;
            count2++;
        }  
    }   
}
