import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line;

        while(!((line = sc.nextLine()).equals("-"))) {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line;

        while(!((line = sc.nextLine()).equals("-"))) {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        }
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line;

        while(!((line = sc.nextLine()).equals("-"))) {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        }
    } main {

        Scanner sc = new Scanner(System.in);
        String line;

        while(!((line = sc.nextLine()).equals("-"))) {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line; line while(!((line = sc.nextLine()).equals("-"))) {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        } !((line = sc.nextLine()).equals("-")) ((line = sc.nextLine()).equals("-")) (line = sc.nextLine()).equals (line = sc.nextLine()) line sc.nextLine() sc.nextLine sc "-" {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        } char[] c = line.toCharArray(); c line.toCharArray() line.toCharArray line line = sc.nextLine() line sc.nextLine() sc.nextLine sc int m = Integer.parseInt(line); m Integer.parseInt(line) Integer.parseInt Integer line for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          } int ii = 0; int ii = 0; ii 0 ii < m ii m ii++ ii++ ii {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          } {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          } line = sc.nextLine() line sc.nextLine() sc.nextLine sc int h = Integer.parseInt(line); h Integer.parseInt(line) Integer.parseInt Integer line char z = 0; z 0 for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              } int I = 0; int I = 0; I 0 I < h I h I++ I++ I {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              } {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              } z = c[0] z c[0] c 0 for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                } int i = 0; int i = 0; i 0 i < c.length - 1 i c.length - 1 c.length c c.length 1 i++ i++ i {
                  c[i] = c[i + 1];
                } {
                  c[i] = c[i + 1];
                } c[i] = c[i + 1] c[i] c i c[i + 1] c i + 1 i 1 c[c.length - 1] = z c[c.length - 1] c c.length - 1 c.length c c.length 1 z System.out.println(String.valueOf(c)) System.out.println System.out System System.out String.valueOf(c) String.valueOf String c String[] args args public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line;

        while(!((line = sc.nextLine()).equals("-"))) {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        }
    }
} public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line;

        while(!((line = sc.nextLine()).equals("-"))) {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line;

        while(!((line = sc.nextLine()).equals("-"))) {
          char[] c = line.toCharArray();

          line = sc.nextLine();
          int m = Integer.parseInt(line);

          for(int ii = 0; ii < m; ii++) {
              line = sc.nextLine();

              int h = Integer.parseInt(line);
              char z = 0;

              for(int I = 0; I < h; I++) {
                z = c[0];
                for(int i = 0; i < c.length - 1; i++) {
                  c[i] = c[i + 1];
                }
                c[c.length - 1] = z;
              }

          }

          System.out.println(String.valueOf(c));

        }
    }
}