import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        }

    }
    private static String shuffle(String cards, int h) {
        return cards.substring(h) + cards.substring(0, h);
    }
}
 import java.util.*; util.* java public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        }

    }
    private static String shuffle(String cards, int h) {
        return cards.substring(h) + cards.substring(0, h);
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        }

    } main {

        Scanner sc = new Scanner(System.in);

        while (true) {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        }

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        } true {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        } String cards = sc.next(); cards sc.next() sc.next sc if (cards.equals("-"))
                break; cards.equals("-") cards.equals cards "-" break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            } m-- > 0 m-- m 0 {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            } int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc cards = shuffle(cards, h) cards shuffle(cards, h) shuffle cards h System.out.println(cards) System.out.println System.out System System.out cards String[] args args private static String shuffle(String cards, int h) {
        return cards.substring(h) + cards.substring(0, h);
    } shuffle {
        return cards.substring(h) + cards.substring(0, h);
    } return cards.substring(h) + cards.substring(0, h); cards.substring(h) + cards.substring(0, h) cards.substring(h) cards.substring cards h cards.substring(0, h) cards.substring cards 0 h String cards cards int h h public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        }

    }
    private static String shuffle(String cards, int h) {
        return cards.substring(h) + cards.substring(0, h);
    }
} public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        }

    }
    private static String shuffle(String cards, int h) {
        return cards.substring(h) + cards.substring(0, h);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            String cards = sc.next();

            if (cards.equals("-"))
                break;

            int m = sc.nextInt();
            
            while (m-- > 0) {
                int h = sc.nextInt();
                cards = shuffle(cards, h);
            }

            System.out.println(cards);
        }

    }
    private static String shuffle(String cards, int h) {
        return cards.substring(h) + cards.substring(0, h);
    }
}

