import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        }
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(sc.hasNext()){
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        } sc.hasNext() sc.hasNext sc {
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        } String card = sc.next(); card sc.next() sc.next sc if (card.equals("-")) break; card.equals("-") card.equals card "-" break; int s = sc.nextInt(); s sc.nextInt() sc.nextInt sc int n = 0; n 0 for (int i=0; i<s; i++) {
                n += sc.nextInt();
            } int i=0; int i=0; i 0 i<s i s i++ i++ i {
                n += sc.nextInt();
            } {
                n += sc.nextInt();
            } n += sc.nextInt() n sc.nextInt() sc.nextInt sc for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            } int i=0; int i=0; i 0 i<card.length() i card.length() card.length card i++ i++ i {
                System.out.print(card.charAt((n+i)%card.length()));
            } {
                System.out.print(card.charAt((n+i)%card.length()));
            } System.out.print(card.charAt((n+i)%card.length())) System.out.print System.out System System.out card.charAt((n+i)%card.length()) card.charAt card (n+i)%card.length() (n+i) n i card.length() card.length card System.out.println("") System.out.println System.out System System.out "" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String card = sc.next(); //最初のカードの並び
            if (card.equals("-")) break;
            int s = sc.nextInt(); //シャッフル回数
            int n = 0;//下から何枚目
            for (int i=0; i<s; i++) {
                n += sc.nextInt();
            }
            for (int i=0; i<card.length(); i++) {
                System.out.print(card.charAt((n+i)%card.length()));
            }
            System.out.println("");
        }
    }
}

