import java.util.MissingResourceException;
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        try{
            while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            }
        }catch(MissingResourceException e){
            System.out.println(e);
        }
        sc.close();
    }
} import java.util.MissingResourceException; MissingResourceException java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        try{
            while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            }
        }catch(MissingResourceException e){
            System.out.println(e);
        }
        sc.close();
    }
} Main public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        try{
            while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            }
        }catch(MissingResourceException e){
            System.out.println(e);
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        try{
            while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            }
        }catch(MissingResourceException e){
            System.out.println(e);
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) try{
            while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            }
        }catch(MissingResourceException e){
            System.out.println(e);
        } catch(MissingResourceException e){
            System.out.println(e);
        } MissingResourceException e {
            System.out.println(e);
        } System.out.println(e) System.out.println System.out System System.out e {
            while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            }
        } while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            } true {
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            } String line = sc.next(); line sc.next() sc.next sc if(line.equals("-")) {
                    break;
                } line.equals("-") line.equals line "-" {
                    break;
                } break; int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                } int i=0; int i=0; i 0 i<m i m i++ i++ i {
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                } {
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                } int h =sc.nextInt(); h sc.nextInt() sc.nextInt sc line = line.substring(h)+line.substring(0, h) line line.substring(h)+line.substring(0, h) line.substring(h) line.substring line h line.substring(0, h) line.substring line 0 h System.out.println(line) System.out.println System.out System System.out line sc.close() sc.close sc String[] arg arg public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        try{
            while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            }
        }catch(MissingResourceException e){
            System.out.println(e);
        }
        sc.close();
    }
} public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        try{
            while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            }
        }catch(MissingResourceException e){
            System.out.println(e);
        }
        sc.close();
    }
} Main
import java.util.MissingResourceException;
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        try{
            while(true){
                String line = sc.next();
                if(line.equals("-")) {
                    break;
                }
                int m = sc.nextInt();
                for(int i=0;i<m;i++){
                    int h =sc.nextInt();
                    line = line.substring(h)+line.substring(0, h);
                }
                System.out.println(line);
            }
        }catch(MissingResourceException e){
            System.out.println(e);
        }
        sc.close();
    }
}
