import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int h = 0;
        while(true){
            String in = scanner.nextLine();
            StringBuilder m = new StringBuilder(in);

            if(m.toString().equals("-")){
                break;
            }

            for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            }
            System.out.println(m.toString());
        }

        scanner.close();
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int h = 0;
        while(true){
            String in = scanner.nextLine();
            StringBuilder m = new StringBuilder(in);

            if(m.toString().equals("-")){
                break;
            }

            for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            }
            System.out.println(m.toString());
        }

        scanner.close();
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int h = 0;
        while(true){
            String in = scanner.nextLine();
            StringBuilder m = new StringBuilder(in);

            if(m.toString().equals("-")){
                break;
            }

            for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            }
            System.out.println(m.toString());
        }

        scanner.close();
    } main {
        Scanner scanner = new Scanner(System.in);
        int h = 0;
        while(true){
            String in = scanner.nextLine();
            StringBuilder m = new StringBuilder(in);

            if(m.toString().equals("-")){
                break;
            }

            for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            }
            System.out.println(m.toString());
        }

        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int h = 0; h 0 while(true){
            String in = scanner.nextLine();
            StringBuilder m = new StringBuilder(in);

            if(m.toString().equals("-")){
                break;
            }

            for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            }
            System.out.println(m.toString());
        } true {
            String in = scanner.nextLine();
            StringBuilder m = new StringBuilder(in);

            if(m.toString().equals("-")){
                break;
            }

            for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            }
            System.out.println(m.toString());
        } String in = scanner.nextLine(); in scanner.nextLine() scanner.nextLine scanner StringBuilder m = new StringBuilder(in); m new StringBuilder(in) if(m.toString().equals("-")){
                break;
            } m.toString().equals("-") m.toString().equals m.toString() m.toString m "-" {
                break;
            } break; for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            } int i = Integer.parseInt(scanner.nextLine()); int i = Integer.parseInt(scanner.nextLine()); i Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner i > 0 i 0 i-- i-- i {
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            } {
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            } h = Integer.parseInt(scanner.nextLine()) h Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner String sub = m.substring(0, h); sub m.substring(0, h) m.substring m 0 h m.delete(0, h) m.delete m 0 h m.append(sub) m.append m sub System.out.println(m.toString()) System.out.println System.out System System.out m.toString() m.toString m scanner.close() scanner.close scanner String[] args args public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int h = 0;
        while(true){
            String in = scanner.nextLine();
            StringBuilder m = new StringBuilder(in);

            if(m.toString().equals("-")){
                break;
            }

            for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            }
            System.out.println(m.toString());
        }

        scanner.close();
    }
} public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int h = 0;
        while(true){
            String in = scanner.nextLine();
            StringBuilder m = new StringBuilder(in);

            if(m.toString().equals("-")){
                break;
            }

            for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            }
            System.out.println(m.toString());
        }

        scanner.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int h = 0;
        while(true){
            String in = scanner.nextLine();
            StringBuilder m = new StringBuilder(in);

            if(m.toString().equals("-")){
                break;
            }

            for(int i = Integer.parseInt(scanner.nextLine()); i > 0; i--){
                h = Integer.parseInt(scanner.nextLine());
                String sub = m.substring(0, h);
                m.delete(0, h);
                m.append(sub);
            }
            System.out.println(m.toString());
        }

        scanner.close();
    }
}

