import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '-') break;
            int t = 0;
            int m = sc.nextInt();
            for(int i = 0;i < m;++i) t += sc.nextInt();
            for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]);
            System.out.println();
            sc.nextLine();
        }
    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '-') break;
            int t = 0;
            int m = sc.nextInt();
            for(int i = 0;i < m;++i) t += sc.nextInt();
            for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]);
            System.out.println();
            sc.nextLine();
        }
    }

} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '-') break;
            int t = 0;
            int m = sc.nextInt();
            for(int i = 0;i < m;++i) t += sc.nextInt();
            for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]);
            System.out.println();
            sc.nextLine();
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '-') break;
            int t = 0;
            int m = sc.nextInt();
            for(int i = 0;i < m;++i) t += sc.nextInt();
            for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]);
            System.out.println();
            sc.nextLine();
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '-') break;
            int t = 0;
            int m = sc.nextInt();
            for(int i = 0;i < m;++i) t += sc.nextInt();
            for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]);
            System.out.println();
            sc.nextLine();
        } true {
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '-') break;
            int t = 0;
            int m = sc.nextInt();
            for(int i = 0;i < m;++i) t += sc.nextInt();
            for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]);
            System.out.println();
            sc.nextLine();
        } char[] c = sc.nextLine().toCharArray(); c sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc if(c[0] == '-') break; c[0] == '-' c[0] c 0 '-' break; int t = 0; t 0 int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i = 0;i < m;++i) t += sc.nextInt(); int i = 0; int i = 0; i 0 i < m i m ++i ++i i t += sc.nextInt(); t += sc.nextInt() t sc.nextInt() sc.nextInt sc for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]); int i = 0,l = c.length; int i = 0 i 0 l = c.length; l c.length c c.length i < l i l ++i ++i i System.out.print(c[(t + i) % l]); System.out.print(c[(t + i) % l]) System.out.print System.out System System.out c[(t + i) % l] c (t + i) % l (t + i) t i l System.out.println() System.out.println System.out System System.out sc.nextLine() sc.nextLine sc String[] args args public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '-') break;
            int t = 0;
            int m = sc.nextInt();
            for(int i = 0;i < m;++i) t += sc.nextInt();
            for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]);
            System.out.println();
            sc.nextLine();
        }
    }

} public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '-') break;
            int t = 0;
            int m = sc.nextInt();
            for(int i = 0;i < m;++i) t += sc.nextInt();
            for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]);
            System.out.println();
            sc.nextLine();
        }
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            char[] c = sc.nextLine().toCharArray();
            if(c[0] == '-') break;
            int t = 0;
            int m = sc.nextInt();
            for(int i = 0;i < m;++i) t += sc.nextInt();
            for(int i = 0,l = c.length;i < l;++i) System.out.print(c[(t + i) % l]);
            System.out.println();
            sc.nextLine();
        }
    }

}