import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        }
    }
    
    private static void solve(String s, int m) {
        int c = 0;
        int l = s.length();
        for (int i = 0;i < m;i++) c += sc.nextInt();
        c %= l;
        if (c == 0) {
            System.out.println(s);
        } else {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        }
    }
}
 import java.util.*; util.* java public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        }
    }
    
    private static void solve(String s, int m) {
        int c = 0;
        int l = s.length();
        for (int i = 0;i < m;i++) c += sc.nextInt();
        c %= l;
        if (c == 0) {
            System.out.println(s);
        } else {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        }
    }
} Main private static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        }
    } main {
        while (true) {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        }
    } while (true) {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        } true {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        } String s = sc.next(); s sc.next() sc.next sc if (s.equals("-")) break; s.equals("-") s.equals s "-" break; solve(s, sc.nextInt()) solve s sc.nextInt() sc.nextInt sc String[] args args private static void solve(String s, int m) {
        int c = 0;
        int l = s.length();
        for (int i = 0;i < m;i++) c += sc.nextInt();
        c %= l;
        if (c == 0) {
            System.out.println(s);
        } else {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        }
    } solve {
        int c = 0;
        int l = s.length();
        for (int i = 0;i < m;i++) c += sc.nextInt();
        c %= l;
        if (c == 0) {
            System.out.println(s);
        } else {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        }
    } int c = 0; c 0 int l = s.length(); l s.length() s.length s for (int i = 0;i < m;i++) c += sc.nextInt(); int i = 0; int i = 0; i 0 i < m i m i++ i++ i c += sc.nextInt(); c += sc.nextInt() c sc.nextInt() sc.nextInt sc c %= l c l if (c == 0) {
            System.out.println(s);
        } else {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        } c == 0 c 0 {
            System.out.println(s);
        } System.out.println(s) System.out.println System.out System System.out s {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        } System.out.print(s.substring(c, l)) System.out.print System.out System System.out s.substring(c, l) s.substring s c l System.out.print(s.substring(0, c)) System.out.print System.out System System.out s.substring(0, c) s.substring s 0 c System.out.println("") System.out.println System.out System System.out "" String s s int m m public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        }
    }
    
    private static void solve(String s, int m) {
        int c = 0;
        int l = s.length();
        for (int i = 0;i < m;i++) c += sc.nextInt();
        c %= l;
        if (c == 0) {
            System.out.println(s);
        } else {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        }
    }
} public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        }
    }
    
    private static void solve(String s, int m) {
        int c = 0;
        int l = s.length();
        for (int i = 0;i < m;i++) c += sc.nextInt();
        c %= l;
        if (c == 0) {
            System.out.println(s);
        } else {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        }
    }
} Main
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("-")) break;
            solve(s, sc.nextInt());
        }
    }
    
    private static void solve(String s, int m) {
        int c = 0;
        int l = s.length();
        for (int i = 0;i < m;i++) c += sc.nextInt();
        c %= l;
        if (c == 0) {
            System.out.println(s);
        } else {
            System.out.print(s.substring(c, l));
            System.out.print(s.substring(0, c));
            System.out.println("");
        }
    }
}

