import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    }
  }

} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    }
  }

} Main public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    }
  } main {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    }
  } Scanner stdin = new Scanner(System.in); stdin new Scanner(System.in) while (true) {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    } true {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    } String str = stdin.next(); str stdin.next() stdin.next stdin if (str.equals("-")) {
        break;
      } str.equals("-") str.equals str "-" {
        break;
      } break; int m = stdin.nextInt(); m stdin.nextInt() stdin.nextInt stdin for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      } {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      } int h = stdin.nextInt(); h stdin.nextInt() stdin.nextInt stdin str = str.substring(h) + str.substring(0, h) str str.substring(h) + str.substring(0, h) str.substring(h) str.substring str h str.substring(0, h) str.substring str 0 h System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    }
  }

} public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    }
  }

} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String str = stdin.next();
      if (str.equals("-")) {
        break;
      }

      int m = stdin.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdin.nextInt();
        str = str.substring(h) + str.substring(0, h);
      }
      System.out.println(str);
    }
  }

}