import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    String card;
    while (!(card = reader.next()).equals("-")) {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    String card;
    while (!(card = reader.next()).equals("-")) {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    }
  }
} Main public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    String card;
    while (!(card = reader.next()).equals("-")) {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    }
  } main {
    Scanner reader = new Scanner(System.in);
    String card;
    while (!(card = reader.next()).equals("-")) {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    }
  } Scanner reader = new Scanner(System.in); reader new Scanner(System.in) String card; card while (!(card = reader.next()).equals("-")) {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    } !(card = reader.next()).equals("-") (card = reader.next()).equals("-") (card = reader.next()).equals (card = reader.next()) card reader.next() reader.next reader "-" {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    } int n = reader.nextInt(); n reader.nextInt() reader.nextInt reader for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      } {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      } int m = reader.nextInt(); m reader.nextInt() reader.nextInt reader String card1 = card.substring(0, m); card1 card.substring(0, m) card.substring card 0 m String card2 = card.substring(m, card.length()); card2 card.substring(m, card.length()) card.substring card m card.length() card.length card card = card2 + card1 card card2 + card1 card2 card1 System.out.println(card) System.out.println System.out System System.out card String[] args args public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    String card;
    while (!(card = reader.next()).equals("-")) {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    String card;
    while (!(card = reader.next()).equals("-")) {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    String card;
    while (!(card = reader.next()).equals("-")) {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    }
  }
}