import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
}
 import java.util.NoSuchElementException; NoSuchElementException java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        try {
            while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) try {
            while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        } NoSuchElementException
                | NumberFormatException e {
            System.out.println(e);
        } System.out.println(e) System.out.println System.out System System.out e {
            while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            }
        } while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            } sc.hasNext() sc.hasNext sc {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            } String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc if (s.equals("-")) {
                    break;
                } s.equals("-") s.equals s "-" {
                    break;
                } break; int m = Integer.parseInt(sc.nextLine()); m Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                } m > 0 m 0 {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                } int h = Integer.parseInt(sc.nextLine()); h Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc String s1 = s.substring(0, h); s1 s.substring(0, h) s.substring s 0 h String s2 = s.substring(h); s2 s.substring(h) s.substring s h s = s2 + s1 s s2 + s1 s2 s1 --m m System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
} Main
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            while (sc.hasNext()) {
                String s = sc.nextLine();
                if (s.equals("-")) {
                    break;
                }
                int m = Integer.parseInt(sc.nextLine());
                while (m > 0) {
                    int h = Integer.parseInt(sc.nextLine());
                    String s1 = s.substring(0, h);
                    String s2 = s.substring(h);
                    s = s2 + s1;
                    --m;
                }
                System.out.println(s);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
}

