import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String[] array = new String[10];
        String s1, s2;
        int m, h, counter = 0;
        while(true){
            array[counter] = scanner.next();
            if(array[counter].equals("-"))break;
            m = scanner.nextInt();
            h = 0;
            for(int i = 0; i < m; i++){
                h += scanner.nextInt();
            }
            h %= array[counter].length();
            s1 = array[counter].substring(0, h);
            s2 = array[counter].substring(h);
            array[counter++] = s2 + s1;
        }
        for(int i = 0; i < counter; i++){
            System.out.println(array[i]);
        }
    }
}
 import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String[] array = new String[10];
        String s1, s2;
        int m, h, counter = 0;
        while(true){
            array[counter] = scanner.next();
            if(array[counter].equals("-"))break;
            m = scanner.nextInt();
            h = 0;
            for(int i = 0; i < m; i++){
                h += scanner.nextInt();
            }
            h %= array[counter].length();
            s1 = array[counter].substring(0, h);
            s2 = array[counter].substring(h);
            array[counter++] = s2 + s1;
        }
        for(int i = 0; i < counter; i++){
            System.out.println(array[i]);
        }
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String[] array = new String[10];
        String s1, s2;
        int m, h, counter = 0;
        while(true){
            array[counter] = scanner.next();
            if(array[counter].equals("-"))break;
            m = scanner.nextInt();
            h = 0;
            for(int i = 0; i < m; i++){
                h += scanner.nextInt();
            }
            h %= array[counter].length();
            s1 = array[counter].substring(0, h);
            s2 = array[counter].substring(h);
            array[counter++] = s2 + s1;
        }
        for(int i = 0; i < counter; i++){
            System.out.println(array[i]);
        }
    } main {
        Scanner scanner = new Scanner(System.in);
        String[] array = new String[10];
        String s1, s2;
        int m, h, counter = 0;
        while(true){
            array[counter] = scanner.next();
            if(array[counter].equals("-"))break;
            m = scanner.nextInt();
            h = 0;
            for(int i = 0; i < m; i++){
                h += scanner.nextInt();
            }
            h %= array[counter].length();
            s1 = array[counter].substring(0, h);
            s2 = array[counter].substring(h);
            array[counter++] = s2 + s1;
        }
        for(int i = 0; i < counter; i++){
            System.out.println(array[i]);
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String[] array = new String[10]; array new String[10] 10 String s1 s1 s2; s2 int m m h h counter = 0; counter 0 while(true){
            array[counter] = scanner.next();
            if(array[counter].equals("-"))break;
            m = scanner.nextInt();
            h = 0;
            for(int i = 0; i < m; i++){
                h += scanner.nextInt();
            }
            h %= array[counter].length();
            s1 = array[counter].substring(0, h);
            s2 = array[counter].substring(h);
            array[counter++] = s2 + s1;
        } true {
            array[counter] = scanner.next();
            if(array[counter].equals("-"))break;
            m = scanner.nextInt();
            h = 0;
            for(int i = 0; i < m; i++){
                h += scanner.nextInt();
            }
            h %= array[counter].length();
            s1 = array[counter].substring(0, h);
            s2 = array[counter].substring(h);
            array[counter++] = s2 + s1;
        } array[counter] = scanner.next() array[counter] array counter scanner.next() scanner.next scanner if(array[counter].equals("-"))break; array[counter].equals("-") array[counter].equals array[counter] array counter "-" break; m = scanner.nextInt() m scanner.nextInt() scanner.nextInt scanner h = 0 h 0 for(int i = 0; i < m; i++){
                h += scanner.nextInt();
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                h += scanner.nextInt();
            } {
                h += scanner.nextInt();
            } h += scanner.nextInt() h scanner.nextInt() scanner.nextInt scanner h %= array[counter].length() h array[counter].length() array[counter].length array[counter] array counter s1 = array[counter].substring(0, h) s1 array[counter].substring(0, h) array[counter].substring array[counter] array counter 0 h s2 = array[counter].substring(h) s2 array[counter].substring(h) array[counter].substring array[counter] array counter h array[counter++] = s2 + s1 array[counter++] array counter++ counter s2 + s1 s2 s1 for(int i = 0; i < counter; i++){
            System.out.println(array[i]);
        } int i = 0; int i = 0; i 0 i < counter i counter i++ i++ i {
            System.out.println(array[i]);
        } {
            System.out.println(array[i]);
        } System.out.println(array[i]) System.out.println System.out System System.out array[i] array i String[] args args
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String[] array = new String[10];
        String s1, s2;
        int m, h, counter = 0;
        while(true){
            array[counter] = scanner.next();
            if(array[counter].equals("-"))break;
            m = scanner.nextInt();
            h = 0;
            for(int i = 0; i < m; i++){
                h += scanner.nextInt();
            }
            h %= array[counter].length();
            s1 = array[counter].substring(0, h);
            s2 = array[counter].substring(h);
            array[counter++] = s2 + s1;
        }
        for(int i = 0; i < counter; i++){
            System.out.println(array[i]);
        }
    }
}

