import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String[] moji;
        moji = new String[200];
        String[] copy;
        copy = new String[200];
        int[] m;
        m = new int[100];
        int[][] h;
        h = new int[100][100];

        int cnt=0;
        while(true){
            moji[cnt] = sc.next();
            if(moji[cnt].equals("-"))
                break;
            m[cnt] = sc.nextInt();
            for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt();

            for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            }
            cnt++;        
        }

        for(int i=0; i<cnt; i++){
            System.out.println(copy[i]);
        }

        sc.close();

    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String[] moji;
        moji = new String[200];
        String[] copy;
        copy = new String[200];
        int[] m;
        m = new int[100];
        int[][] h;
        h = new int[100][100];

        int cnt=0;
        while(true){
            moji[cnt] = sc.next();
            if(moji[cnt].equals("-"))
                break;
            m[cnt] = sc.nextInt();
            for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt();

            for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            }
            cnt++;        
        }

        for(int i=0; i<cnt; i++){
            System.out.println(copy[i]);
        }

        sc.close();

    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String[] moji;
        moji = new String[200];
        String[] copy;
        copy = new String[200];
        int[] m;
        m = new int[100];
        int[][] h;
        h = new int[100][100];

        int cnt=0;
        while(true){
            moji[cnt] = sc.next();
            if(moji[cnt].equals("-"))
                break;
            m[cnt] = sc.nextInt();
            for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt();

            for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            }
            cnt++;        
        }

        for(int i=0; i<cnt; i++){
            System.out.println(copy[i]);
        }

        sc.close();

    } main {
        Scanner sc = new Scanner(System.in);

        String[] moji;
        moji = new String[200];
        String[] copy;
        copy = new String[200];
        int[] m;
        m = new int[100];
        int[][] h;
        h = new int[100][100];

        int cnt=0;
        while(true){
            moji[cnt] = sc.next();
            if(moji[cnt].equals("-"))
                break;
            m[cnt] = sc.nextInt();
            for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt();

            for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            }
            cnt++;        
        }

        for(int i=0; i<cnt; i++){
            System.out.println(copy[i]);
        }

        sc.close();

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] moji; moji moji = new String[200] moji new String[200] 200 String[] copy; copy copy = new String[200] copy new String[200] 200 int[] m; m m = new int[100] m new int[100] 100 int[][] h; h h = new int[100][100] h new int[100][100] 100 100 int cnt=0; cnt 0 while(true){
            moji[cnt] = sc.next();
            if(moji[cnt].equals("-"))
                break;
            m[cnt] = sc.nextInt();
            for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt();

            for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            }
            cnt++;        
        } true {
            moji[cnt] = sc.next();
            if(moji[cnt].equals("-"))
                break;
            m[cnt] = sc.nextInt();
            for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt();

            for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            }
            cnt++;        
        } moji[cnt] = sc.next() moji[cnt] moji cnt sc.next() sc.next sc if(moji[cnt].equals("-"))
                break; moji[cnt].equals("-") moji[cnt].equals moji[cnt] moji cnt "-" break; m[cnt] = sc.nextInt() m[cnt] m cnt sc.nextInt() sc.nextInt sc for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt(); int i=0; int i=0; i 0 i<m[cnt] i m[cnt] m cnt i++ i++ i h[cnt][i] = sc.nextInt(); h[cnt][i] = sc.nextInt() h[cnt][i] h[cnt] h cnt i sc.nextInt() sc.nextInt sc for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            } int i=0; int i=0; i 0 i<m[cnt] i m[cnt] m cnt i++ i++ i {
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            } {
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            } if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]); i==0 i 0 copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]) copy[cnt] copy cnt moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]) moji[cnt].substring(h[cnt][i]) moji[cnt].substring moji[cnt] moji cnt h[cnt][i] h[cnt] h cnt i moji[cnt].substring(0, h[cnt][i]) moji[cnt].substring moji[cnt] moji cnt 0 h[cnt][i] h[cnt] h cnt i copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]) copy[cnt] copy cnt copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]) copy[cnt].substring(h[cnt][i]) copy[cnt].substring copy[cnt] copy cnt h[cnt][i] h[cnt] h cnt i copy[cnt].substring(0, h[cnt][i]) copy[cnt].substring copy[cnt] copy cnt 0 h[cnt][i] h[cnt] h cnt i cnt++ cnt for(int i=0; i<cnt; i++){
            System.out.println(copy[i]);
        } int i=0; int i=0; i 0 i<cnt i cnt i++ i++ i {
            System.out.println(copy[i]);
        } {
            System.out.println(copy[i]);
        } System.out.println(copy[i]) System.out.println System.out System System.out copy[i] copy i sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String[] moji;
        moji = new String[200];
        String[] copy;
        copy = new String[200];
        int[] m;
        m = new int[100];
        int[][] h;
        h = new int[100][100];

        int cnt=0;
        while(true){
            moji[cnt] = sc.next();
            if(moji[cnt].equals("-"))
                break;
            m[cnt] = sc.nextInt();
            for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt();

            for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            }
            cnt++;        
        }

        for(int i=0; i<cnt; i++){
            System.out.println(copy[i]);
        }

        sc.close();

    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String[] moji;
        moji = new String[200];
        String[] copy;
        copy = new String[200];
        int[] m;
        m = new int[100];
        int[][] h;
        h = new int[100][100];

        int cnt=0;
        while(true){
            moji[cnt] = sc.next();
            if(moji[cnt].equals("-"))
                break;
            m[cnt] = sc.nextInt();
            for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt();

            for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            }
            cnt++;        
        }

        for(int i=0; i<cnt; i++){
            System.out.println(copy[i]);
        }

        sc.close();

    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String[] moji;
        moji = new String[200];
        String[] copy;
        copy = new String[200];
        int[] m;
        m = new int[100];
        int[][] h;
        h = new int[100][100];

        int cnt=0;
        while(true){
            moji[cnt] = sc.next();
            if(moji[cnt].equals("-"))
                break;
            m[cnt] = sc.nextInt();
            for(int i=0;i<m[cnt];i++)
                h[cnt][i] = sc.nextInt();

            for(int i=0;i<m[cnt];i++){
                if(i==0)
                    copy[cnt] = moji[cnt].substring(h[cnt][i]) + moji[cnt].substring(0, h[cnt][i]);
                else
                    copy[cnt] = copy[cnt].substring(h[cnt][i]) + copy[cnt].substring(0, h[cnt][i]);
            }
            cnt++;        
        }

        for(int i=0; i<cnt; i++){
            System.out.println(copy[i]);
        }

        sc.close();

    }
}
