import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String str = sc.next();
            if(str.equals("-"))
                break;
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String str = sc.next();
            if(str.equals("-"))
                break;
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String str = sc.next();
            if(str.equals("-"))
                break;
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String str = sc.next();
            if(str.equals("-"))
                break;
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true)
        {
            String str = sc.next();
            if(str.equals("-"))
                break;
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        } true {
            String str = sc.next();
            if(str.equals("-"))
                break;
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        } String str = sc.next(); str sc.next() sc.next sc if(str.equals("-"))
                break; str.equals("-") str.equals str "-" break; int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            } {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            } int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc String a = str.substring(0,h); a str.substring(0,h) str.substring str 0 h String b = str.substring(h); b str.substring(h) str.substring str h str = b + a str b + a b a 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){
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String str = sc.next();
            if(str.equals("-"))
                break;
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String str = sc.next();
            if(str.equals("-"))
                break;
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        }
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            String str = sc.next();
            if(str.equals("-"))
                break;
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++)
            {
                int h = sc.nextInt();
                String a = str.substring(0,h);
                String b = str.substring(h);
                str = b + a;
            }
            System.out.println(str);
        }
    }
}
